How to select every 54th image in the folder?
Show older comments
Suppose we have two folders A and B , both contain images.
Let folder A have 54 images:a1,a2,...,a54
folder B have 540 images: b1,b2,...,b540.
I want to select 10 images in B for each image in A, in the following way
for a1 select b1,b55, b109, b163, b217, b271, b325, b379, b433, b487
for a2 select b2,b56, b110, b164, b218, b272, b326, b380, b434, b488
.
.
.
for a54 select b54, b108, b162, b216, b270, b324, b378, b432, b486,b540
that is select every 54th entry.
Now I want to find uaci and npcr such that for each 'image a' I want to use 10 'image b', so that corresponding to each 'image a' I will get 10 uaci and npcr, and the function is attached.
Accepted Answer
More Answers (1)
A = 'D:\Your\A';
B = 'D:\Your\B';
AList = dir(fullfile(A, 'a*.jpg'));
BList = dir(fullfile(B, 'b*.jpg'));
nB = numel(BList);
for iA = 1:numel(AList)
imageA = fullfile(A, AList(iA).name);
indexB = iA:54:nB;
imageBList = fullfile(B, {BList(indexB).name});
for iB = 1:imageBList
imageB = imageBList{iB};
...
end
end
If you are sure that all file names a1 to a54 and b1 to b540 are existing, you can create the file names automatically also:
A = 'D:\Your\A';
B = 'D:\Your\B';
for iA = 1:54
imageA = fullfile(A, sprintf('a%d.jpg', iA));
for iB = iA:54:540
imageB = fullfile(B, sprintf('b%d.jpg', iB));
... process imageA and imageB now
end
end
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!