Applescript photoshop for you gurus

How do i get the colour of a pixel with coords x,y.

what i want to do is get the pixel colour and then count them and see how the image is broken up. This is to help work.

any ideas???

You would have to select the pixel and get its histograms for each channel. From there you can get the color values. This is for an RGB file, after the pixel was selected:

tell application "Adobe Photoshop 7.0"
	set r to histogram of channel "red" of current document
	set g to histogram of channel "green" of current document
	set b to histogram of channel "blue" of current document
end tell
set theValues to {}
set x to 1
repeat 256 times
	if item x of r is 1 then
		set theValues to theValues & (x - 1)
	end if
	set x to x + 1
end repeat
set x to 1
repeat 256 times
	if item x of g is 1 then
		set theValues to theValues & (x - 1)
	end if
	set x to x + 1
end repeat
set x to 1
repeat 256 times
	if item x of b is 1 then
		set theValues to theValues & (x - 1)
	end if
	set x to x + 1
end repeat

The result (theValues) is a list of three integers, representing the red, green, and blue values of the pixel. A histogram of one pixel would be a list of 256 integers, with 255 zeros, and one 1. It’s the position of the 1 that gives you the value, except you need to subtract 1, because a histogram starts at level 0 (0-255). So if the 1 is item 34 in the list, it represents level 33.

I’m thinking there might be a more efficient way of writing the script, but this is the gist of what you need to do. If you want the values for each individual pixel in an image, that would involve selecting and running through this routine for each one. Getting a script to select each pixel consecutively is something I haven’t worked on yet, but I would imagine it’s tedious as all heck.