MATLAB: I have attached two photos of component. In one of the piece there is a portion cut. Is it possible to produce output with or without comparison with the default using image processing. can someone provide the code

image processingImage Processing Toolboximage segmentation

Best Answer

Simply take the red channel, threshold it, find the area, and if the area is less than some minimum allowable area, alert the user. Try this
rgbImage = imread(filename);
redChannel = rgbImage(:,:,1);
binaryImage = redChannel < 128; % Whatever...
binaryImage = bwareaopen(binaryImage, 100);
labeledImage = bwlabel(binaryImage, 4);
measurements = regionprops(labeledImage, 'Area');
allAreas = [measurements.Area];
minAllowableArea = 500; % Whatever.
for k = 1 : length
fprintf('Area = %d pixels.', allAreas(k));
if allAreas(k) < minAllowableArea
message = sprintf('Blob #%d is too small at %d pixels', k, allAreas(k));
uiwait(warndlg(message));
end
end
That's untested so you might have to tweak it.