Clear Filters
Clear Filters

How to retrieve specific pixels from an image based on the label

1 view (last 30 days)
Hello everyone,
I am conducting some works on image restoration, particularly on specular reflection removal. I have obtained some results and I would like to evaluate the performance of my method using some quantitative metrics suh PSNR, SSIM, COV, etc. However, I would like to compute these metrics only for the regions that have restored. Please, how can I retrieve only the pixels of the restored regions from the processed images? This is the code I wrote for computing the evaluation metrics for the entire image.
allPSNR = zeros(1, numImages);
allSSIM = zeros(1, numImages);
for k = 1 : numImages
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
baseFileName1 = theFiles1(k).name;
fullFileName1 = fullfile(theFiles1(k).folder, baseFileName1);
lab = imread(fullFileName);
img = imread(fullFileName1);
allPSNR(k) = psnr(img, lab);
allSSIM(k) = ssim(img, lab);
end
meanPSNR = mean(allPSNR);
meanSSIM = mean(allSSIM);
  3 Comments
Patrice Gaofei
Patrice Gaofei on 1 Jan 2021
Thank you for your comments. Yes, I do have the binary image that will help map out the regions. That is what I call label.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 1 Jan 2021
See if it will work for one-dimensional vectors:
allPSNR(k) = psnr(img(binaryImage), lab(binaryImage));
allSSIM(k) = ssim(img(binaryImage), lab(binaryImage));
  6 Comments
Image Analyst
Image Analyst on 2 Jan 2021
Of course pixel values at different locations can be equal. What if you had a completely uniform image where every single pixel in the entire image had the same gray scale value or RGB color? Maybe I'm not understanding what you're trying to say.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!