I read a DICOM image and I extracted some of its characteristics such as width and height. Now I want to save in a variable the number of total pixels of the image. This is the code:
info = dicominfo(filename);
width = info.Width;
height = info.Height;
colorType = info.ColorType;
format = info.Format;
size = info.FileSize;
numberOfPixels = width*height;
k = info.BitDepth;
And these are the prints:
Size: 256 x 256
Color type: grayscale
Format: DICOM
Size: 137024 bytes
NumberOfPixels: 65535
The numberOfPixels
value is wrong. Why?
I thought it was a cast problem and so I also tried adding uint32(width*height)
but nothing, I get 65535 instead of 65536.
Why?
Thank you
You should cast before multiplying e.g. uint32(width)*uint32(height)
.