필터 지우기
필터 지우기

Following is the error occured during thresholding

조회 수: 1 (최근 30일)
Balaji M. Sontakke
Balaji M. Sontakke 2016년 4월 23일
답변: Image Analyst 2016년 4월 23일
Following is the error occured in my code. please, can you help me for sorting out this error.
Error using .* Integers can only be combined with integers of the same class, or scalar doubles.
Error in thresholding (line 13) thix1=max(ix,level1.*ones(size(ix)));

채택된 답변

Image Analyst
Image Analyst 2016년 4월 23일
Try this:
hix1 = max(ix, uint8(level1).*ones(size(ix), 'uint8'));
or this:
hix1 = uint8(max(double(ix), level1.*ones(size(ix))));

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 4월 23일
Your datatype for your image, ix, is uint8 . Your level1 is a double. You cannot use max() to combine uint8 and double.
Suppose one of the entries was uint8(4) and level1 was double(7.283), then since double(7.283) is larger than uint8(4) then you would expect double(7.283) to be the result for that location. But for uint8(9) since that is greater than double(7.283) you would expect uint8(9) to be the result for there. You would thus be expecting double() to be the result at one place and uint8() to be the result at another place, but it is not possible to have uint8 and double in the same array.
You will need to convert your ix to double or you will need to convert your level1 to uint8
By the way, you can leave level1 as a scalar instead of using level1.*ones(size(ix))

태그

Community Treasure Hunt

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

Start Hunting!

Translated by