天天看点

提取图像对应坐标的像素matlab,matlab如何提取图像中像素最大的8个值,并求出对应坐标...

lz 这个应当有多种思路

因为只要求最大8个值及对应坐标 所以用排序 过了点

设图像前8个值所组成的1-D数组为MAX_value,对应1-D坐标数组为MAX_coor_x,MAX_coor_y,threshold为MAX_value的中各元素的最小值,A为对应图像,i,j为宽,高,k为栈指针,threshold_coor为threshold在MAX_value中对应的位置(防止有多个最小值,所以可能是个数组),threshold_coor_multi为有多个最小值的情况下,相同值的个数,0表示各不相同。

Pseudo:

i,j initialization

for i,j scan every pixel of the image except the first 8 pixels

%%in-loop initialization

gray value with coordinates of the first 8 pixels to MAX_value

calculate threshold_coor_multi in MAX_value

coordinates of the first 8 pixels to MAX_coor_x, MAX_coor_y

threshold_coor = the order no. of smallest in MAX_value

threshold = smallest in MAX_value

%%in-loop computation

if A[i,j] >=threshold

then

A[i,j] to MAX_value[threshold_coor]

i,j to MAX_coor_x[threshold_coor],MAX_coor_y[threshold_coor]

if A[i,j] = threshold  %%case without variation of thresold

then

threshold_coor_multi++

update threshold_coor

break

end if

if threshold_coor_multi >0 %%case for equal smallest gray values

then

threshold_coor_multi --

update threshold_coor

else

update threshold

update threshold_coor

end if

end for

个人观点 仅供参考

[本帖最后由 silas_xue 于 2009-3-27 07:00 编辑]