Manual and Automatic Image Recognition
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I need to identify bright and dark spots in an image, but the contrast of these spots is not very good. Processing the image by taking the maximum and minimum contrast values from a portion of the image is always difficult. Someone told me that defining the circularity of contrast could help identify these spots, and this method is feasible. My code is provided below.
My question is: I want to manually designate a region, and then have the program automatically re-identify the bright and dark spots in the designated area after it finishes identifying the rest of the image. For example, in the image below, is there a way to help me identify the black and white circles? Additionally, I want to apply a Voronoi Diagram to the identified spots in the image.
code:
clc
clear
% read image
inpict = imread('image.png');
inpict = im2gray(inpict);
% logfilter image
t=1;
sigma=sqrt(t);
Fsize = ceil(sigma*3)*2+1;
h1 = fspecial('gaussian',[Fsize,Fsize],sigma);
h2 = fspecial('log',[Fsize,Fsize],sigma);
filter1 = uint8(imfilter(inpict,h1,'replicate'));
filter2 = t * imfilter(inpict, h2, 'replicate');
bw = filter2 >=0;
filter2= uint8(filter2 + 128);
figure
subplot(221), imshow(filter1);
title(sprintf('filtered by Gaussinan, t =%d',t));
subplot(222), imshow(filter2, []);
title(sprintf('filtered by log, t =%d',t));
subplot(223), imshow(bw*255);
title(sprintf('binarized, t =%d',t));
%Automatic Image Recognition
inpict = imflatfield(filter1,30); %Flat-field correction of images
inpict = adapthisteq(inpict);
inpict = imresize(inpict, 2);
inpict = imadjust(inpict);
%Automatic Image Recognition (1.Creating Local Extreme Masks)
minex = 30; %black
maxex = 20; %white
maskmx = imextendedmax(inpict, minex); % black
maskmn = imextendedmin(inpict, maxex); % white
% 2.Removal of part of the plaque on the border
maskmx = imclearborder(maskmx);
maskmn = imclearborder(maskmn);
% filtering based on patch attributes
minc = 0.2;
maxecc = 0.87;
minarea = 10;
% Maximum Mask
Lmx = bwlabel(maskmx);
Smx = regionprops(maskmx, 'circularity', 'eccentricity', 'area');
goodblobs = find([Smx.Circularity] >= minc ...
& [Smx.Eccentricity] <= maxecc ...
& [Smx.Area] >= minarea);
maskmx = any(Lmx == permute(goodblobs, [1 3 2]), 3);
% minimum value mask
Lmn = bwlabel(maskmn);
Smn = regionprops(maskmn, 'circularity', 'eccentricity', 'area');
goodblobs = find([Smn.Circularity] >= minc ...
& [Smn.Eccentricity] <= maxecc ...
& [Smn.Area] >= minarea);
maskmn = any(Lmn == permute(goodblobs, [1 3 2]), 3);
% Visualisation masks and images
outpict = cat(3, im2uint8(maskmx), im2uint8(maskmn), inpict);
imshow(outpict, 'border', 'tight');
0 Commenti
Risposte (1)
Image Analyst
il 30 Mag 2024
Most bright spots looks like they're surrounded by a dark spot/ring. Do you want to count those as one of the dark spots? Do you want binary maps of both the dark spots and bright spots independently? Once you " identify bright and dark spots in an image" what do you want to do with them? Identify, to me, means segment, in other words make a binary image of where they are, but you must want something beyond that, like a count or brightness or area fraction or something.
Have you tried to obtain a better image by using optical filters over the lens, or changing the illumination or geometry of the image capture setup?
To find the "skiz" of an image, which you called Voronoi, see
0 Commenti
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!