Notifications
Clear all

[Closed] Pixel value

im trying to find the position of one pixel in 32 hdri file that have the brightest value.. it seems that its finding the wrong one…
help :banghead:

img = selectBitMap caption:"Select a Bitmap" 
HDRI_W = img.width 
HDRI_H = img.height 

global	pixel = [0,0]
global  maxval = 0

	progressstart "Serching..."
	
  		(
			progressupdate (y as float /HDRI_H *100)
			
  			row = getpixels img [0,y] HDRI_W  linear:false
  			for x = 1 to row.count 
				do
				(
  				pixelValue = row[x].v
  				if pixelValue > maxval do
					(
  					pixel = [x-1,y]
  					maxval = pixelValue
					)
				)
  		)	

progressend ()
close img
messagebox ((img.width as string) +"
"+ (img.height as string) +"
"+ 
			(pixel.x as string) +"
"+ ( pixel.y as string)+"
"+(maxval as string))
5 Replies
 lo1

Did you forget your Y loop?

There is one good and fast solution in this thread.

Yes rotem i forgot the y loop but it`s still no finding the right one…

why do you add the 0.3 0.59 0.11 to the rgb?

row = for pix in pixel_line collect									
				(0.3*pix.r + 0.59*pix.g + 0.11*pix.b)
1 Reply
(@aaandres)
Joined: 10 months ago

Posts: 0

See this article:
https://en.wikipedia.org/wiki/Grayscale

“In the Y’UV and Y’IQ models used by PAL and NTSC, the rec601 luma (Y’) component is computed as Y’=0.299R’+0.587G’+0.114B’.
The ITU-R BT.709 standard used for HDTV developed by the ATSC uses different color coefficients, computing the luma component as Y’=0.2126R’+0.7152G’+0.0722B’.”

Thanx Andres now i know:)
Is there a deference between pixel RGB and PixelValue

row = for pix in pixel_line collect									
				(0.3*pix.r + 0.59*pix.g + 0.11*pix.b)

and

	row = getpixels img [0,y] HDRI_W  
  			for x = 1 to row.count 
				do
				(
  				pixelValue = row[x].v
  				if pixelValue > maxval do
					(

If my goal is to work with 32 bit file and find the brightest pixel?