I am the beginer for doing simple image subtration to obtain defect image.

Illustration
CHEE HOON SEOW - 2022-02-19T10:53:00+00:00
Question: I am the beginer for doing simple image subtration to obtain defect image.

Hi, I am the beginer for doing simple image subtration to obtain defect image. Is it possible to make it only show the defect image if nothing difference wont show? clc   clear   close all   warning off;   x=imread('origin.jpg');   y=imread('capture.jpg');   [g, c, d]=size(x);   y=imresize(y,[g,c]);   subplot(1,3,1);   imshow(x);   title('origin image');   subplot(1,3,2);   imshow(y);   title('capture image');   subplot(1,3,3);   imshow(x-y);   title('defect occur if difference colour shown');    

Expert Answer

Profile picture of John Williams John Williams answered . 2025-11-20

Is it possible to make it only show the defect image if nothing difference wont show?
 
may be add some judge rule?such as
clc
clear
close all
warning off;
x=imread('origin.jpg');
y=imread('capture.jpg');
[g, c, d]=size(x);
y=imresize(y,[g,c]);
subplot(1,3,1);
imshow(x);
title('origin image');
subplot(1,3,2);
imshow(y);
title('capture image');
bw = find((x-y) > 1);
if numel(bw) > 1
    subplot(1,3,3);
    imshow(x-y);
    title('defect occur if difference colour shown');
end

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!