필터 지우기
필터 지우기

help me to solve error in integer coding

조회 수: 2 (최근 30일)
izyan hanum
izyan hanum 2015년 4월 25일
댓글: Geoff Hayes 2015년 4월 25일
i dont know why have error in this coding. please help me to solve it
Error using ./ Integers can only be combined with integers of the same class, or scalar doubles.
Error in try1 (line 21) imgN=double(img-min(img(:)))/(max(img(:)-min(img(:))));
%# read image
img = imread('C:\Users\User\Pictures\N2.jpg');
%# normalize to 0...1
imgN = double(img-min(img(:)))/(max(img(:)-min(img(:))));
th1=graythresh(imgN);
th2 = graythresh(imgN(imgN>th1));
cellMsk = imgN>th1;
nucMsk = imgN>th2;
figure,imshow(cellMsk+nucMsk,[])

답변 (1개)

Geoff Hayes
Geoff Hayes 2015년 4월 25일
izayn - the problem in the line
imgN = double(img-min(img(:)))/(max(img(:)-min(img(:))));
is that the
double(img-min(img(:)))
is a multi-dimensional array (the same size as your matrix) and is of class/type double. The
(max(img(:)-min(img(:))))
will be a scalar of class/type that is the same as your image. I get the same error if I read an image where each element is a 8-bit unsigned integer. To get around this problem, just cast the right half of the equation to be of double type too. Your equation then becomes
imgN = double(img-min(img(:)))/double(max(img(:)-min(img(:))));
Try the above and see what happens!
  댓글 수: 3
izyan hanum
izyan hanum 2015년 4월 25일
picture below
Geoff Hayes
Geoff Hayes 2015년 4월 25일
izayn - if you are observing an error, please post it.

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

카테고리

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