How to find the coordinate defect location in image any document to refer? Please help I am fyp student in mechanical engineering
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
CHEE HOON SEOW
el 25 de Feb. de 2022
Comentada: CHEE HOON SEOW
el 25 de Feb. de 2022
clc
clear
close all
warning off;
x=imread('origin.jpg');
y=imread('capture.jpg');
diffImage = imabsdiff(x, y);
threshold = 5;
mask = diffImage >= threshold;
imshow(mask)
props = regionprops(mask, 'Area')
allAreas = [props.Area]
if ~isempty(props)
fprintf('Found %d defect areas.\n', length(props))
else
fprintf('Found no defect areas.\n')
end
Respuesta aceptada
DGM
el 25 de Feb. de 2022
I'm going to assume that the attached image is the mask derived from x and y.
[mask map] = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/906590/image.png');
mask = rgb2gray(ind2rgb(mask,map))>0.5;
props = regionprops(mask, 'Area','centroid'); % you can get both
allAreas = [props.Area] % row vector of areas
allCentroid = vertcat(props.Centroid) % Mx2 array of centroids [x y]
imshow(mask); hold on
plot(allCentroid(:,1),allCentroid(:,2),'kx') % mark the centroids
% same as before
if ~isempty(props)
fprintf('Found %d defect areas.\n', length(props))
else
fprintf('Found no defect areas.\n')
end
3 comentarios
Image Analyst
el 25 de Feb. de 2022
@CHEE HOON SEOW then you should definitely check out my Image Segmentation Tutorial in my File Exchange.
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

