What is the benefit of casting image into double after reading in Matlab

Hello, I asked several questions here.in every answer it is recommended that caste the image to double.
So i want to know what is the benefit of casting image to double. My segmentation results are not good.so i am thinking on every factor. plz help.Thank you

 Accepted Answer

It's not necessarily true that you should cast to double. It depends on the circumstances and what you're trying to do or measure. I don't think it should make the segmentation worse though.

4 Comments

I applied Laplaicain of Guassian,Then Thresholding And then Morphological opening and closing and at last segmeanton....But the segmeantation results are different from ground truth...i also post a question before in which you suggest me to cast to double http://www.mathworks.com/matlabcentral/answers/153204-morphological-operation-result-is-not-displayed-after-applying-laplacian-of-gaussian-on-the-image
so i want to know the importance of casting.
I don't know if imfilter used conv2() internally so that's why I suggested that. conv2() required floating point arrays. Also if you're applying a floating point kernel, such as a gaussian where you multiply and add, I wanted to make sure that after multiplication it didn't force it to be a uint8 because that would round the value. It's quite possible that some algorithm you invented might give a different answer than some ground truth image you arrived at via some other means. In that case you have to adapt your algorithm if your ground truth is really the truth.
Ok sir i want to know that this function input should be in double or unit8.This is my first operation on my medical image image. The image is also attached here.
function img_BlueRation = Fun_BlueRationConv(img)
R = img(:,:,1);
G = img(:,:,2);
B = img(:,:,3);
img_BlueRation = ((100 * B)./(1+R+G)) .* (256./(1+B+R+G));
end
Kindly sir also tell me what is clipping in this sense.
Just make a little experiment to see. Look at this code and see the two different results:
R = uint8(9);
G = uint8(19);
B = uint8(139);
img_BlueRation = ((100 * B)./(1+R+G)) .* (256./(1+B+R+G))
whos img_BlueRation
R = double(9);
G = double(19);
B = double(139);
img_BlueRation = ((100 * B)./(1+R+G)) .* (256./(1+B+R+G))
whos img_BlueRation
img_BlueRation =
18
Name Size Bytes Class Attributes
img_BlueRation 1x1 1 uint8
img_BlueRation =
730.377668308703
Name Size Bytes Class Attributes
img_BlueRation 1x1 8 double
So it seems to me you should case img to double before you do that kind of math on it.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!