selecting an image from folder

3 次查看(过去 30 天)
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
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 个评论
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
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 个评论
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');

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by