selecting an image from folder

I have 30 images in a folder,I have to select only21st image from it,please help,i tried this code but only first image is shown
I have 30 images in folder named photos
path='D:\photos\';
files=dir(strcat(path,'*.jpg'))
for k=1:numel(files(21))%numel(files)
file_name=files(k).name;
image_name=strcat(path,file_name);
I=imread(image_name);
figure,imshow(I)
end

댓글 수: 2

kash
kash 2011년 12월 29일
chandra can u tell how to select 1st,6tf,11th,16th,21st,26th images and storing them in folder
Image Analyst
Image Analyst 2011년 12월 29일
Look up the mod() function to take every 5th one.

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

 채택된 답변

Chandra Kurniawan
Chandra Kurniawan 2011년 12월 22일

1 개 추천

path='D:\photos\';
jpeg_files = dir(fullfile(path,'*.jpg'));
for cnt = 1 : 21
I{cnt} = imread(fullfile(path,jpeg_files(cnt).name));
figure,imshow(I{cnt});
end

댓글 수: 12

kash
kash 2011년 12월 22일
i get an error when executing it
Cell contents assignment to a non-cell array object.
Error in ==> Untitled at 26
I{cnt} = imread(fullfile(path,jpeg_files(cnt).name));
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 22일
what are the size of 'jpeg_files' in workspace?
30x1 struct or 0x1 struct??
kash
kash 2011년 12월 22일
Chandra I ment i need only the 21st figure and not all 21 figures
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 22일
Oh sorry.
Now, you said 21st image in your folder??
Then the code is :
path='D:\photos\';
files = dir(fullfile(path,'*.jpg'));
I = imread(fullfile(path,files(21).name));
figure,imshow(I); title(files(21).name);
This is, right??
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 22일
If you consider to select single image,
then you don't need to use for loop
-> for k=1:numel(files(21))
And 'numel(files(21))' is returns 1, you don't need
to write this??
kash
kash 2011년 12월 22일
tHANKS Chadra
kash
kash 2011년 12월 22일
Chandra finally one question I have extracted features of images and have stored in .mat file i have 1row and 80 columns of size[1x359double] ,Now i have to take query image and find euclidean distance for image retrieval,can u guide plz
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 22일
Euclidean distance is defined as :
D(i,j)=sqrt((dataset1(i,1)-dataset2(j,1))^2 + ...
(dataset1(i,2)-dataset2(j,2))^2);
right??
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 22일
What are the size of extracted feature of query image?
kash
kash 2011년 12월 22일
but i have to retrieve the image how it can be done,have i to extract all the 4 features for that query image and store in .mat file
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 22일
Can you show me about 'feature vector of query image' and 'feature vector that you saved in your .MAT file?
kash
kash 2011년 12월 22일
Feature vector is [1x359double]od 1row and 80 colomns
have i have to extract same feature vector for query image and store in .mat file for retrieving the image

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

추가 답변 (1개)

Chandra Kurniawan
Chandra Kurniawan 2011년 12월 22일

2 개 추천

Then you just need to pass your feature vector 1x80 and
feature vector of query image in
suppose that dataset1 is feature vector 1x80
dataset2 is feature vector of query image
function D = DistEuclidian(dataset1, dataset2)
[m1 n1] = size(dataset1);
[m2 n2] = size(dataset2);
D = zeros(m1, m2);
for i = 1 : m1
for j = 1 : m2
D(i, j) = sqrt((dataset1(i, 1) - dataset2(j, 1)) ^ 2 + ...
(dataset1(i, 2) - dataset2(j, 2)) ^ 2);
end
end
And you'll get the Distance matrix.
Then make a limit. If all values in Distance matrix lower than your limit,
We can say that your query image is match with feature vector 1x80

댓글 수: 7

FIR
FIR 2011년 12월 22일
But Chandra How to retrieve the image finally
kash
kash 2011년 12월 22일
Chandra how to find the min and max limit please tell,before this can we rank the imaged based on features extraction and calculate indices for that
kash
kash 2011년 12월 22일
AFter that i need to retrieve the nearest distance image and have to subplot,both query image and retrieved image
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 22일
Please send me the MAT file of 'feature vector 1x80'
and tell me what are feature vector of query image.
It's hard if I only imagine about that.
kash
kash 2011년 12월 22일
this is the feature vector of my dataset image
http://www.sendspace.com/file/s4xidk
feature vector of both the query image and data set image are same images...
the feature vectors are
http://www.sendspace.com/file/6xnrta
kash
kash 2011년 12월 28일
i have dataset of 80 numbers=[1:1:80]
now i want to take first 8 values ,multiply each value by 2 and divide each by 2,so i will have 8 values each for multiplication and division,and then want to find average for that multilaction values and division values,same way i eant to perform for those 80 values from 1st 8,2nd 8,3rd 8........10th8 please help
Image Analyst
Image Analyst 2011년 12월 28일
Did you try
% Multiply by 2 and divide by 2, for some weird reason.
newVector = (2*data80) / (2*data80); % Not sure of the point.
% Get running average.
output = conv(newVector, ones(1,8)/8, 'valid');

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

카테고리

도움말 센터File 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