I saw a lot of image processing examples and before conducting any analysis the image is transfered into double. Is it essential? and what is the benefit from doing so?

 채택된 답변

Image Analyst
Image Analyst 2020년 4월 5일

0 개 추천

No, it's usually not. But sometimes it is, like if you want to use conv2(). It has to do with how MATLAB likes to multiply variables of different classes.

댓글 수: 2

Could you please give me some cases in which I should transfer the image into double before carrying out any processes?
Image Analyst
Image Analyst 2020년 4월 5일
Other than conv2(), I can't think of any off the top of my head. But you obviously must have had some cases in mind because you're the one who brought up the question. Care to share those cases?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Paul Hoffrichter
Paul Hoffrichter 2020년 12월 4일

1 개 추천

MATLAB when using mixed mode arithmetic, will try to save memory.
250 + 10 = 260, right?
>> x =double(250) + uint8(10);
>> x
x =
uint8
255
In other languages, like C/C++, the rule is to maximize precision. Avoid mixed mode arithmetic unless you need it. There is no error or warning provided, by default, in the above code.

댓글 수: 4

in the normal case, all the data (like numbers) are stored in double or uint8?
Normally, data in MATLAB defaults to double unless specified by a function to be otherwise.
When using imread, it is usual to get a integer type, but not necessarily, uint8. Here you also see uint16, and others.
In fact, I see that TIFF can be returned as single floating point number:
"imread reads and converts TIFF images as follows:
  • YCbCr images are converted into the RGB colorspace.
  • All grayscale images are read as if black = 0, white = largest value.
  • 1-bit images are returned as class logical.
  • 16-bit floating-point images are returned as class single."
thank you
Glad to help.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by