How to create two different sets of images from one set of images using indexing?
조회 수: 1 (최근 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)
댓글 수: 0
채택된 답변
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:
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!