For some reason when i run this script x always equals one when it's suppose to be a matrix.
The program is for star dectection from the image and x suppose to be the threshold with steps.
stars=imread('stars.jpg'); GREY = rgb2gray(stars); figure,imshow(GREY); big = max( max (GREY)); %255 threshold = .4; bwimage = GREY >= threshold*big; figure(2),imshow(bwimage); step=0.01;
for x = [0.0:step:1.0] BW = GREY > big.*x; count = sum(BW>=x); end
Thanks ill greatly appreciate the help
No products are associated with this question.
"x" is used as a loop control variable. During the loop it will have only one value at a time; after the loop it will be the last value that it was assigned in the loop.
You have a problem that each iteration of the loop, you are overwriting "BW" and "count".
xvals = 0 : step: 1; numx = length(xvals); for K = 1 : numx x = xvals(K); BW = GREY > big.*x; count(K) = sum(BW(:)); end