필터 지우기
필터 지우기

What is the problem in the for loop?

조회 수: 2 (최근 30일)
Shaila parvin
Shaila parvin 2014년 3월 17일
편집: Image Analyst 2014년 3월 17일
I've a problem in the for loop to extract texture features of images of a folder. The problem is in this line:
Im2=ComputeRankTransform(filename);
Can anyone please help me to access all images??
clc;
Im1=ComputeRankTransform('bi4.jpg');
folder = fullfile('E:\4-2\Thesis_codes\texture\code\dependencies');
srcFiles = dir(fullfile(folder, '*.jpg'));
for i = 1 : length(srcFiles)
% determins how many images are there in the folder,
filename = fullfile(folder,srcFiles(i).name);
thisImage = imread(filename);
Im2=ComputeRankTransform(thisImage);
sizeOfIm1=size(Im1);
sizeOfIm2=size(Im2);
if(sizeOfIm1==sizeOfIm2)
if(Im1==Im2)
fprintf('Yes\n');
else
fprintf('No\n');
end
else
fprintf('No Dimension\n');
end
end

채택된 답변

per isakson
per isakson 2014년 3월 17일
That is hard to tell based on the information you provide. However, here are some links on debugging in Matlab
  댓글 수: 2
Shaila parvin
Shaila parvin 2014년 3월 17일
You can ask me any information you need:
My code is:
clc;
Im1=ComputeRankTransform('bi4.jpg');
%Im2=ComputeRankTransform('bi9.jpg');
folder = fullfile('E:\4-2\Thesis_codes\texture\code\dependencies');
srcFiles = dir(fullfile(folder, '*.jpg'));
loopCount=0;
srcFiles = dir(fullfile(folder, '*.jpg'));
for i = 1 : length(srcFiles)
fprintf('for loop %i',i);
% determins how many images are there in the folder,
filename = fullfile(folder,srcFiles(i).name);
%filename
thisImage = imread(filename);
%a=size(thisImage);
%a
%Im2=ComputeRankTransform(thisImage);
Im2=ComputeRankTransform(filename);
Im2
sizeOfIm1=size(Im1);
sizeOfIm2=size(Im2);
%sizeOfIm2
sizeOfIm2
sizeOfIm1
if(sizeOfIm1==sizeOfIm2)
if(Im1==Im2)
fprintf('Yes\n');
else
fprintf('No\n');
end
else
fprintf('No Dimension\n');
end
loopCount=loopCount+1;
end
loopCount
The function is:
function RT = ComputeRankTransform(I);
%Computes the rank transform of an image
%Input: I (one-channel image)
%Output: RT (rank transform
[rows cols] = size(I);
nPixels = rows*cols;
I = reshape(I, 1, nPixels);
[sorted, indices] = sort(I, 'descend');
RT(indices(1:nPixels)) = 1:nPixels;
RT = reshape(RT, rows, cols);
end
Image Analyst
Image Analyst 2014년 3월 17일
편집: Image Analyst 2014년 3월 17일
The problem is we don't know what you mean when you say "help me to access all images" You say
thisImage = imread(filename);
so as far as we can tell, you're accessing the image right there with that line of code, and we don't know why you're asking.
By the way, you don't need to put useless tags (which I deleted) like "matlab" or "code" or similar on your post. All posts here are on MATLAB code.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Support에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by