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 編輯]