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?

2 vues (au cours des 30 derniers jours)

Réponse acceptée

Image Analyst
Image Analyst le 11 Jan 2015
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.

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by