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

1 次查看(过去 30 天)
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

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by