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

1 view (last 30 days)
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

Accepted Answer

Image Analyst
Image Analyst on 7 Jul 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 Comment
Bryant
Bryant on 7 Jul 2014
Sorry about that, I only need 1 folder processed. I used uigetfile to test something else earlier so I forgot to erase MultiSelect.

Sign in to comment.

More Answers (0)

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!