access to each image channel existing in a folder
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
assia assia
el 30 de Jun. de 2021
Comentada: assia assia
el 30 de Jun. de 2021
Hello folks,
I'm trying to access to each image channel existing in the folder and calculate after PSNR and SSIM of each channel. I developped this code but I still have an error to access to each image channel. Any idea to make it work please.
imgFolderStokes = fullfile('saveAssia/StokesPaarameters/');
imgFolderLinear = fullfile('saveAssia/Linear_Separable_Model/');
imgStokes = imageDatastore(imgFolderStokes);
imgLinear = imageDatastore(imgFolderLinear);
numOfImgStokes = length(imgStokes.Files);
numOfImgLinear = length(imgLinear.Files);
for ii = 1:numOfImgStokes
for jj = 1:numOfImgLinear
Stokes{ii} = fitsread(imgStokes.Files{ii})
Linear{jj} = fitsread(imgLinear.Files{ii})
Iu_s = Stokes(:,:,1);
Ip_s = Stokes(:,:,2);
Theta_s = Stokes(:,:,3);
Iu_L = Linear(:,:,1);
Iu_L = imresize( Iu_L,[size(Iu_s,1) size(Iu_s,2)]);
Ip_L = Linear(:,:,2);
Theta_L = Linear(:,:,3);
[ssim] = ssim(uint8(Iu_s),uint8(Iu_L));
[psnr] = psnr(uint8(Iu_s),uint8(Iu_L));
end
end
avr_peaksnr = sum([psnr]) / len([psnr])
avr_snr = sum([ssim]) / len([psnr])
fprintf('\n The Peak-SNR value is %0.4f', avr_peaksnr);
fprintf('\n The SNR value is %0.4f \n', avr_snr);
ERROR
Index in position 3 exceeds array bounds (must not exceed 1).
Error in PSNR_SSIM (line 96)
Ip_s = Stokes(:,:,2);
4 comentarios
Respuesta aceptada
Image Analyst
el 30 de Jun. de 2021
Editada: Image Analyst
el 30 de Jun. de 2021
Evidently
Error in PSNR_SSIM (line 96)
Ip_s = Stokes(:,:,2);
means that there is no third dimension to your Stokes array. The third dimension has a max of 1, basically meaning there is no third dimension. It's a gray scale monochrome image, not a RGB color, or multispectral, or volumetric image with multiple slices along the third (Z) dimension.
In fact, Stokes is not an image at all - it's a cell array because you did this:
Stokes{ii} = fitsread(imgStokes.Files{ii})
so it's a cell array - a 1-D array of cells. Inside each cell may be an image but you have to use braces to get to it:
thisImage = Stokes{ii}; % Get contents of cell.
See the FAQ:
3 comentarios
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!