How to select different data points in different images in a loop?
Afficher commentaires plus anciens
I wish to select a different number of data points for different image in this loop but I can't do that since it gives me an error "Unable to perform assignment because the size of the left side
is 3-by-1 and the size of the right side is 4-by-1.". Is there a way to make the 3-by-1 to 4-by-1 by adding zeros as needed?
clear
clc
close all
% Read images in order from 1 to 925.
% Files are in the "myFolder" directory.
imageFolder = 'D:\Research File\September 26\C001H001S0001';
for k = 1:925
tifFilename = sprintf('C001H001S0001000%03d.tif', k);
fullFileName = fullfile(imageFolder, tifFilename);
if exist(fullFileName, 'file')
imageData = imread(fullFileName);
Pic=imageData/64;
else
warningMessage = sprintf('Warning: image file does not exist:\n%s', fullFileName);
uiwait(warndlg(warningMessage));
end
image(Pic);
colormap(bone);
xlabel('$x$','fontsize',24,'interpreter','latex');
ylabel('$y$','fontsize',24,'interpreter','latex');
[i(:,k),j(:,k)]=getpts;
end
2 commentaires
KALYAN ACHARJYA
le 12 Jan 2020
Modifié(e) : KALYAN ACHARJYA
le 12 Jan 2020
Make it more simple please, so that the question can be understood easily. As per the description of the questions, the issue is not with images call right.
Q1: As per my understanding you have sucessfully called the images and wish to get the random spatial location from the image??
Ans:: Yes or no
Q2: Are there all images have same size?
Ans:: Yes/No
Q3: As you mentioned about adding zeros, zero padding right, to make image for equal size??
Ans:
Muhammad Ahmad Seemab Khan
le 12 Jan 2020
Modifié(e) : Muhammad Ahmad Seemab Khan
le 12 Jan 2020
Réponse acceptée
Plus de réponses (1)
KALYAN ACHARJYA
le 12 Jan 2020
Modifié(e) : KALYAN ACHARJYA
le 12 Jan 2020
Hope I understand the question??
Yes, lets suppose three data points points in image 1. Please stored in a array or matrix (whatever). Assigned those array data as a cell array elements to store, then only proceeed for next image call operation, is this?
im_data_points={};
for k=
image=imread()
[r c]=size(image);
num_data_points=input('Enter the data Points Required: ');
im_data=[];
iter=1;
while iter<=num_data_points
r_data=randi(r);
c_data=randi(c);
pix_data=image(r_data_c_data);
im_data=[im_data; r_data,c_data,pix_data];
iter=iter+i;
end
im_data_points{k}=im_data
end
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
