필터 지우기
필터 지우기

Integers can only be combined with integers of the same class, or scalar doubles.

조회 수: 6 (최근 30일)
Sajina Rose
Sajina Rose 2019년 8월 21일
댓글: Guillaume 2019년 8월 21일
red=I(:,:,1);
green=I(:,:,2);
blue=I(:,:,3);
R=(0.7*GRmean+(1-0.7)*LRmean);
G=(0.7*GGmean+(1-0.7)*LGmean);
B=(0.7*GBmean+(1-0.7)*LBmean);
r=red./R; %ERROR
g=green./G;
b=blue./B;
  댓글 수: 3
Sajina Rose
Sajina Rose 2019년 8월 21일
Yeah.....I defined formula for that in my code.......It's nothing but just global and local mean of RGB....
Ted Shultz
Ted Shultz 2019년 8월 21일
What are your variable types? (command "whos") will tell you.
What error are you getting?

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

답변 (1개)

John D'Errico
John D'Errico 2019년 8월 21일
READ THE ERROR MESSAGE!
R = uint8(1:5);
>> R./double(R)
Error using ./
Integers can only be combined with integers of the same class, or scalar doubles.
Is double( R ) a scalar double? In fact, it is not. It is a vector of doubles.
So MATLAB will not allow you to perform that operation. The information was completely contained in the error message, if you think about what it says and what you just did.
Can you fix it? Well, yes, that is trivial. In the line:
r=red./R;
Change it to read
r=double(red)./R;
red is a vector of INTEGERS. R is a vector of doubles. So to do that operation, you need to convert the vector red into a vector of doubles.
  댓글 수: 1
Guillaume
Guillaume 2019년 8월 21일
Another option would be to convert the original image to double with im2double:
I = im2double(I);
%rest of the code as it was
matlab expects images of type double to have intensities in the range 0-1, so im2double may be better than straight double conversion.
But yes, the error message explained what the problem is.

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

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by