필터 지우기
필터 지우기

How to create two different sets of images from one set of images using indexing?

조회 수: 4 (최근 30일)
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)

채택된 답변

Rohit
Rohit 2022년 8월 8일
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:
  댓글 수: 1
Sweta
Sweta 2022년 8월 18일
Thank You so much Rohit for getting back to me , but for huge stacks of images like 200 or 300 images , I can write all the index numbers, also if want to take every 3rd alternative image instead of one alternative image, this function wont be applicable. Thats why I need more dynamic code with variables where I can put the no. of total frames and just put the index by which I need seperation.....like "3" i.e. first 3 images in stack 1 then next three images in stack 3.
Thank you again for your help and your time

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by