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
댓글 수: 0
채택된 답변
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?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!