How can I compare Images and choose the best based on which has the least white spots?

1 次查看(过去 30 天)
Hello,
I want to ask a question about a project.
I have many different images, but in some of them there are some white spots. I want somehow to check in these pics if there are many of them and if so to reject these images. To make it clear, I want to create an algorithm that will check those images(compare them) and choose the best. The best image will be the image that has the fewest white spots.
For example I have these 3 images :
As you can see the 3rd image is the image with the fewer white spots.
So, in my algorithm I want somehow to check (maybe in a loop) images like this and to come up with the pic with the fewer white spots.
Any suggestions of how I can do this?
Thank you in advance!
  2 个评论
DGM
DGM 2021-3-21
I suppose it depends on how easily the white defects can be separated from the background, and what exactly we mean by "least".
I'll assume that we can reliably detect white defects using some combination of contrast adjustment and thresholding to yield a logical map describing the defects alone.
From there, we can either count the number of spots (i.e. if 'least' means 'fewest number of spots'), or we can use the sum or average of the map (i.e. if 'least' means 'least amount of the image').
Counting the spots can be done using bwlabel() and unique(), though I'm sure there are lots of different ways to approach this. You might want to browse the IPT docs on image segmentation if that's the route you want to take.
Tsitsos Dimitris
Tsitsos Dimitris 2021-3-21
编辑:Tsitsos Dimitris 2021-3-21
Hello DGM and thank you for your answer.
Maybe I didn't make clear what I want so let me explain to you with an example.
For example I have these 3 images :
As you can see the 3rd image is the image with the fewer white spots.
So, in my algorithm I want somehow to check (maybe in a loop) images like this and to come up with the pic with the fewest white spots.
I hope that now I made myself clear.
Thank you again for your time!

请先登录,再进行评论。

回答(1 个)

DGM
DGM 2021-3-21
编辑:DGM 2021-3-21
Technical image processing isn't exactly my background, but I'll take a shot at this. If we want to find the image with the fewest number of white groups:
% read images and build a multiframe array
% this can be done in various ways.
% i'd normally use imstacker() and mimread() from the MIMT, but this works
% the only reason i'm making a multiframe array is so that i can index
% through it in a simple loop.
A=rgb2gray(imread('train1.jpg'));
B=rgb2gray(imread('train2.jpg'));
C=rgb2gray(imread('train3.jpg'));
alltrainpix=cat(4,A,B,C);
clear A B C
numframes=size(alltrainpix,4);
% we could probably do some pre-processing before thresholding, but i'm not going to.
% how we pick a threshold depends on what we expect. I'm just picking something arbitrary.
whitemap=(alltrainpix>254);
% at this point, we have to ask whether the smallest isolated groups should count
% if they don't, they can be removed using morphological tools like imopen() or bwareaopen()
% otherwise, we can count the number of connected groups in each frame of the thresholded image
groupcounts=zeros([numframes 1]);
for f=1:numframes
L=bwlabel(whitemap(:,:,1,f),8);
groupcounts(f)=numel(unique(L));
end
% observe the number of connected groups per frame
groupcounts
which returns
groupcounts =
232
198
60
That said, I'm not so sure that a metric other than object count wouldn't better describe the image quality. Someone else may be able to offer a more appropriate suggestion.
  2 个评论
Image Analyst
Image Analyst 2021-3-21
That's fine for a start. If it doesn't work because the "white spots" vary in brightness depending on where in the image they are, then you'll have to do a locally adaptive algorithm and suddenly the situation just got a whole lot harder.
Tsitsos Dimitris
Tsitsos Dimitris 2021-3-21
编辑:Tsitsos Dimitris 2021-3-21
Hello guys and thank you for your help.
Let me also add a new clue to the mystery..
As I have already mentioned I have many images and I want to find from them the best looking image. My images goes from dark images like this :
or more clear like this :
Among these 2 photos there are plenty of others.
What I want to do is to find between them the best image. The best image means a combination of the most clear image and an image with the fewest white spots.
The problem is that I really can't think about a way to solve this problem.
From the one hand I know how to find the most clear photo because the photos are scaled from the less (1st photo) to the most clear photo (2nd photo). But as you can see the method that I use create some white artefacts when I try to dehaze the input image. As a result I decided to print all the images that I can and among them to find the best image (combination of clear and white artefacts free image).
So, I try to create an algorithm that will do this, but I can't :p
Any help would be REALLY usefull!
Thank you again

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by