Using Confocal algorithm on MATLAB

4 views (last 30 days)
Marina Ghobrial
Marina Ghobrial on 10 Dec 2021
Edited: Image Analyst on 10 Dec 2021
Hi, I was trying to make a code, where I input a set of images and then I would use confocal algorithm on them. However, I am having errors in the code, Can someone please help?
rootFolder = '/Users/marinaghobrial/Downloads/compressed-2';
%imds=Image2D
imds = imageDatastore (fullfile(rootFolder), ...
'LabelSource',"foldernames", 'IncludeSubfolders',true);
figure
for i = 1:20
subplot(2,2,i);
imshow(imds)
end
I = imread(imds);
PSF = fspecial('gaussian',5,5);
V = 0.002;
blurred_noisy = imnoise(blurred,'gaussian',0,V);
luc1 = deconvlucy(blurred_noisy,PSF,5);
imshow(luc1)
title('I = imread(imds);
PSF = fspecial('gaussian',5,5);
V = 0.002;
blurred_noisy = imnoise(blurred,'gaussian',0,V);
luc1 = deconvlucy(blurred_noisy,PSF,5);
imshow(luc1)
title('Confocalled images')

Answers (1)

Image Analyst
Image Analyst on 10 Dec 2021
Edited: Image Analyst on 10 Dec 2021
This is not correct syntax:
title('I = imread(imds);
You need to have a string in the title argument, like
title('This is my image');
And your display loop needs to be like this:
rootFolder = '/Users/marinaghobrial/Downloads/compressed-2';
imds = imageDatastore (fullfile(rootFolder), ...
'LabelSource',"foldernames", 'IncludeSubfolders',true);
figure
allFileNames = imds.Files;
%allFileNames = allFileNames(1:16); % Show just the first 16.
numImages = length(allFileNames)
plotRows = ceil(sqrt(numImages))
allPossibleFormats = imformats;
validImageCount = 0;
for k = 1:numImages
thisFileName = allFileNames{k};
% Display the file as an image, if you can.
try
thisImage = imread(thisFileName);
validImageCount = validImageCount + 1;
subplot(plotRows, plotRows, validImageCount);
imshow(thisImage)
[folder, baseFileName, ext] = fileparts(thisFileName);
title([baseFileName, ext]);
drawnow;
catch
end
end
g = gcf;
g.WindowState = 'maximized'

Community Treasure Hunt

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

Start Hunting!