Find the best between 2 images

조회 수: 4 (최근 30일)
Tsitsos Dimitris
Tsitsos Dimitris 2021년 10월 17일
댓글: yanqi liu 2021년 10월 19일
Hello,
For my project I have these 2 photos:
As you can see there are some differences between these 2 images.
What I want to do is to compare somehow these 2 images and to reject the second one because of the white pixels at the up right corner.
To be more clear, I want to compare these 2 images and to recognize that the second one has many white pixels and reject it.
  댓글 수: 2
DGM
DGM 2021년 10월 18일
편집: DGM 2021년 10월 18일
Code that will identify one of these two images is likely going to be a complete waste of time unless:
  1. It's going to be used on other images
  2. You know what the other images are
  3. you have a formal description of what the rejection criteria are
If all you have are two images and you already know which is rejected, then your task is done.
Otherwise maybe you can do some sort of histogram analysis or saturated pixel count? Without knowing items 2 &3, it's hard to know what is even appropriate.
Re: saturated pixel count, you could look at the images and try to decide what the rejection criteria are supposed to be...
A = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/770036/image.jpeg');
B = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/770041/image.jpeg');
Asat = [nnz(A == 0) nnz(A == 255)] % [black white]
Asat = 1×2
9353 2257
Bsat = [nnz(B == 0) nnz(B == 255)] % [black white]
Bsat = 1×2
10271 5861
Which might be adequate to identify and reject B, if you only care about white and if all your pictures have similar content and defects.
Consider the example
X = rgb2gray(imread('peppers.png'));
X = imadjust(X,stretchlim(X,0));
A = imadjust(X,[0 0.89]);
B = imadjust(X,[0.07 1]);
imshow(A)
clf
imshow(B)
Which image is "worse"? Both have been damaged to approximately the same degree.
% total saturated pixels
Asat = [nnz(A == 0) nnz(A == 255)] % [black white]
Asat = 1×2
14 2714
Bsat = [nnz(B == 0) nnz(B == 255)] % [black white]
Bsat = 1×2
2486 313
% number of pixels contributed by defect
dw = sum(A==255,'all')-sum(X==255,'all') % white pixels clipped in A
dw = 2401
db = sum(B==0,'all')-sum(X==0,'all') % black pixels clipped in B
db = 2472
If only overexposure matters, the answer might be clear. In order to get meaningful results, you need to define what's meaningful.
Tsitsos Dimitris
Tsitsos Dimitris 2021년 10월 18일
편집: Tsitsos Dimitris 2021년 10월 18일
@DGM first of all thank you for your help!
To answer to your question:
  1. It's going to be used on other images (Yes the method that i try to create will be used in a dataset of similar photos live above)
  2. You know what the other images are (I know the dataset because I created and it is based on a method for image dehazing. Based on this method I generated a dataset of photos where the differences between them are two:
  • How clear the photo is (for example at the previous example we can see that the second photo is a haze-free image)
  • And how many white pixels exists in those photos.
3. you have a formal description of what the rejection criteria are (The criteria is that I want to find the best photo among a dataset of similar photos).
To be more clear I have generate many photos and among these I want to find the best possible.
Best possible photo means the clearest possible photo without these white pixels.
I hope that I halped you to understand the idea.
In any case, thank you again for your interest.

댓글을 달려면 로그인하십시오.

채택된 답변

yanqi liu
yanqi liu 2021년 10월 18일
sir,may be use some score, such as
clc; clear all; close all;
im1 = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/770036/image.jpeg');
im2 = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/770041/image.jpeg');
score1 = [brisque(im1) niqe(im1)]
score1 = 1×2
28.0054 3.9894
score2 = [brisque(im2) niqe(im2)]
score2 = 1×2
28.9105 4.5575
  댓글 수: 2
Tsitsos Dimitris
Tsitsos Dimitris 2021년 10월 18일
First of all thank you for your answer, but I would like to ask, how can I use this in my method that I want to detect the photo with the fewest white pixels?
yanqi liu
yanqi liu 2021년 10월 19일
sir, it is No-Reference Image Quality Assessment
so, the value higher and the quality lower

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by