error using imsubtract
이전 댓글 표시
I've been using imsubtract, i want to replace the background with black, but why that appear only in black ... no image object .. what is wrong ...?
답변 (3개)
Alex Taylor
2011년 9월 12일
Megah,
I'd also recommend that you use the MATLAB minus operator instead of imsubtract to perform elementwise subtraction on two images:
image3 = im2double(image1) - im2double(image2)
The imadd and imsubtract functions are old and predate support for integer math in base MATLAB.
The MATLAB math operators are better maintained and in general will exhibit better performance:
>> a = rand(4000,4000); >> b = rand(4000,4000);
>> tic; for i = 1:100; imsubtract(a,b); end; toc
Elapsed time is 17.827151 seconds.
>> tic; for i = 1:100; a-b; end; toc
Elapsed time is 8.206314 seconds.
- Alex.
Wolfgang Schwanghart
2011년 8월 18일
Hi Megah, apparently both variables don't have the same class. Try
image3 = imsubtract(im2double(image1),im2double(BWfinal))
[edited according to WRs suggestion]
댓글 수: 3
Walter Roberson
2011년 8월 18일
I would suggest that it would make more sense to use im2double() instead of double(), so that the values get rescaled to the [0,1] range for both images, instead of the subtraction results varying widely according to which class each of the images happened to be.
Wolfgang Schwanghart
2011년 8월 18일
Again, I have learned something new. Thanks, Walter.
Megah Putri
2011년 8월 18일
Pramod Bhat
2011년 8월 25일
0 개 추천
convert them to the same class. both the images shud be in the same format.
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!