Effacer les filtres
Effacer les filtres

Selecting Images to crop? Cannot convert from cell to logical?

2 vues (au cours des 30 derniers jours)
Bryant
Bryant le 7 Juil 2014
Commenté : Bryant le 7 Juil 2014
Hello all,
Is there any way to analyze the set of images given by uigetdir by getting their filenames without extensions? Or is there any other alternatives to this? If I run the code as is, I get:
Conversion to logical from cell is not possible.
Error in foldergrab (line 8)
if(strcat(LFAfile{1}, '.jpg'))
Script:
[FileName,PathName] = uigetdir(pwd, '*.jpg; *.png; *.tif; *.gif','Please select the folder containing the images to analyze.', 'MultiSelect', 'on');
for LFAfile={FileName};
LFA = imread(strcat(LFAfile{1}, '.jpg'));
%Uncropped set to 0 means that the image must still be manually
%cropped
if(uncropped==0)
%Image will appear in upper panel.
%Manually crop by drawing a box around the test and control lines
%Make sure the control line is in the left half of the crop window
%and the test line is in the right half of the crop window
subplot(3,1,1);
LFAGray = imcrop(rgb2gray(LFA));
close all;
else
LFAGray = rgb2gray(LFA);
end
end
end

Réponse acceptée

Image Analyst
Image Analyst le 7 Juil 2014
No. You need the extension to call imread. The problem is you're doing it wrong. See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F Use uigetdir() just to get the folder, and after that, just follow the FAQ to call dir which gets the filenames. Why are you calling uigetdir and telling them to select a folder but you have multiselect on? Do you want to allow them to process multiple folders?
  1 commentaire
Bryant
Bryant le 7 Juil 2014
Sorry about that, I only need 1 folder processed. I used uigetfile to test something else earlier so I forgot to erase MultiSelect.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by