error using imsubtract

8 visualizaciones (últimos 30 días)
Megah Putri
Megah Putri el 18 de Ag. de 2011
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 ...?

Respuestas (3)

Alex Taylor
Alex Taylor el 12 de Sept. de 2011
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
Wolfgang Schwanghart el 18 de Ag. de 2011
Hi Megah, apparently both variables don't have the same class. Try
image3 = imsubtract(im2double(image1),im2double(BWfinal))
[edited according to WRs suggestion]
  3 comentarios
Wolfgang Schwanghart
Wolfgang Schwanghart el 18 de Ag. de 2011
Again, I have learned something new. Thanks, Walter.
Megah Putri
Megah Putri el 18 de Ag. de 2011
thank you wolfgang schwanghart,,, ^_^ ,,, thank you walter roberson ^_^

Iniciar sesión para comentar.


Pramod Bhat
Pramod Bhat el 25 de Ag. de 2011
convert them to the same class. both the images shud be in the same format.

Community Treasure Hunt

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

Start Hunting!

Translated by