Question
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
John Williams
PhD Expert
Answered Sep 9, 2026
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
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related image processing Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →