loading
 
finding heighest white pixel on each x pixel column
James Dickinson from Australia  [49 posts]
13 year
Hi all,

I've failed to figure this one out!

What I am wanting to do is find the y value of the hieghest white pixel in each x column of pixels in the image.

Does anyone know how this can be done?
James Dickinson from Australia  [49 posts] 13 year
never mind I got it

if VariableExists("STARTUP") = false then
  dim height_array(319)
  setvariable "STARTUP", 1
end if
pixel_array = GetPixels()
pixel_array_size = ubound(pixel_array)
red_value = 0
blue_value = 0
green_value = 0
min_rgb = 250
current_y = 0
step = 10


for current_x = 0 to 319
  current_y = 0
  for index = (current_x*3) to (pixel_array_size-3)
    blue_value = pixel_array(index)
    if blue_value >= min_rgb then
      green_value = pixel_array(index+1)
      if green_value >= min_rgb then
        red_value = pixel_array(index+2)
        if red_value >= min_rgb then
          height_array(int(current_x/step)) = current_y
          pixel_array(index) = 0
          pixel_array(index+1) = 0
          pixel_array(index+2) = 255
        end if
      end if
    else
      if height_array(current_x) > 0 then
        index = pixel_array_size
      end if
    end if
    index = index + (320*3) - 1
    current_y = current_y + 1
  next
  current_x = current_x + step - 1
next
setpixels pixel_array
setvariable "test", height_array(int(20/5))

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index