I have 12 input images in the inputImages folder with names 001_in.png, 002_in.png ….. 012_in.png. Also I have the ground truths of these images 001_GT.png, 002_GT.png … 012_GT.png in another folder named GroundTruth. I want to read and display these 12 images and for each of these 12 images, I have to calculate the PSNR value with respect to the ground truth stored in the GroundTruth folder. How will I get the ground truth for a particular input image ? Here's my code. I have tried to retrieve the image names and compare them. But, I am getting name1 = * , name 2 = * , last= 1×0 empty char array.
location1='G:\MTech\InputImages\*.png';ds1=imageDatastore(location1)while(hasdata(ds1)) I=read(ds1); figure,imshow(I),title('Input Image'); [filepath1,name1,ext1] = fileparts(location1) underlineLocation1 = strfind(name1, '_') first = name1(1:underlineLocation1-1) %Getting the image name upto underscore
location2='G:\MTech\GroundTruth\*.png'; ds2=imageDatastore(location2) while(hasdata(ds2)) ref=read(ds2); figure,imshow(ref),title('Ground Truth'); [filepath2,name2,ext2] = fileparts(location2) underlineLocation2 = strfind(name2, '_') last = name2(1:underlineLocation2-1) if first==last [peaksnr, snr] = psnr(I, ref); fprintf('\n The Peak-SNR value of final output is %0.4f', peaksnr); end end end
Best Answer