Eyeon:Script/Reference/Applications/Fuse/Classes/Image/GetPixel
From VFXPedia
< Eyeon:Script | Reference | Applications | Fuse | Classes | Image
Contents |
Summary
The GetPixel function is used to retrieve the values of a specific pixel in an Image. This uses actual pixel co-ordinates, and must always be within image bounds.
Usage
Image:GetPixel(integer x_position, integer y_position, object pixel)
- x_position
- The position of the pixel to get on the x axis
- y_position
- The position of the pixel to get on the y axis
- pixel
- The Pixel object that will receive the color values of the image's pixel.
Example
A simple 8 bit histogram function
local p = Pixel() local histoR = {} local histoG = {} local histoB = {} local histoA = {} local r,g,b,a -- initialise the histogram table for i = 0,255 do histoR[i] = 0 histoG[i] = 0 histoB[i] = 0 histoA[i] = 0 end for y=0,Height-1 do if self.Status ~= "OK" then break end for x=0,Width-1 do img:GetPixel(x,y, p) -- convert float 0..1 values into int 0.255 r = math.floor(p.R * 255) g = math.floor(p.G * 255) b = math.floor(p.B * 255) a = math.floor(p.A * 255) -- check for out-of-range colors if r >= 0 and r <= 255 then histoR[r] = histoR[r] + 1 end if g >= 0 and g <= 255 then histoG[g] = histoG[g] + 1 end if b >= 0 and b <= 255 then histoB[b] = histoB[b] + 1 end if a >= 0 and a <= 255 then histoA[a] = histoA[a] + 1 end end end
Tips for GetPixel (edit)
EyeonTips:Script/Reference/Applications/Fuse/Classes/Image/GetPixel