how can i declare variables in for loop
30 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
majed majed
am 20 Jun. 2015
Bearbeitet: Stephen23
am 19 Jun. 2019
hi everyone I want to write a function to deal with image which has been divided to N regions with regionprops function : imageregion = [1 2 3 4 ... n] , for every region i in that image I want to declare variables using for loop like this
for i=1:N
vector1=ismember(labelimage,1)>0;
vector2=ismember(labelimage,2)>0;
.
.
vectorn=ismember(labelimage,n)>0;
end
I try to apply that code but i failed . could any help me thank you
3 Kommentare
Weitere Antworten (2)
Jan
am 20 Jun. 2015
Short summary: Don't do this! Use an array instead of a pile of variables with an index hidden in the name.
0 Kommentare
Image Analyst
am 20 Jun. 2015
There is no reason to do that. You are extracting individual blobs one at a time into "n" binary images with just one blob. Then you're doing that same thing "N" times. There is no reason to do it more than once, and there is not even any reason to do it once. You don't need n images, and don't need to generate n images N times. Why do you think you need to do this? What do you think it will allow you to achieve?
2 Kommentare
Image Analyst
am 21 Jun. 2015
Then use a cell array. See the FAQ http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F and see my Image Segmentation Tutorial in my File Exchange http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862. In there I show you how to filter blobs based on certain feature values.
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!