How to create two different sets of images from one set of images using indexing?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a set of 100 images with dimensions 1000×500×100 where 100 is pixel per A- line, 500 lines per frame. Lets say I index them in code using i = 1:100. So I need to make two stacks of images one having i=1,2 is in stack 1 then i=3,4 goes in stack 2. Then again i =5,6 goes in stack 1 and then i=7,8 goes in stack 2. This way i want to distribuyte the hundred images. The code I use to aquire the images is shared below.
Thank You for helping me.
tic, clear all; close all; clc;
Adrs=uigetdir('\.','Select Folder for Phase image');
file_name=dir(fullfile(Adrs,'*.bmp'));
total_num=numel(file_name);
h = waitbar(0,'Reading Phase image files.... Please Wait');
for I=1:total_num
file1=fullfile(Adrs,file_name(I).name);
img_phs(:,:,I)=(imread(file1));
waitbar(I/total_num,h);
end
close(h)
0 commentaires
Réponse acceptée
Rohit
le 8 Août 2022
Example:
I am assuming the “data” to be consisting of 10 frames of 5*5 black and white images and then I distribute them into 2 sets (“set1”, ”set2”) based on indexing. The code for the same is below:
Code:
data=randi(20,5,5,10);
frame=data(:,:,1);
Indexing frames
index1=[1,2,5,6,9,10];
set1=data(:,:,index1);
index2=[3,4,7,8];
set2=data(:,:,index2);
Below is the documentation to help with array and matrices creation and manipulation:
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!