필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Bryant
Bryant 2014년 7월 7일
댓글: Bryant 2014년 7월 7일
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에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by