Yes, I knwo what you are looking for!
OK, although this binary stuff is way over my head, I was able to modify the color -> greyscale script according to the logic in my first response
Code: Select all
on mouseUp
# Experiment with this valaue, which decides how grey a pixel must be to trun black or white
put 128 into tThreshold
## 128 = 50% grey!
local tPixel, tImgPosition, tGray, tImage
put the imageData of image "Image" into tImage
# repeat for all the pixels in the image
repeat with tPixel = 0 to (height of image "Image" * width of image "Image") - 1
put tPixel * 4 into tImgPosition
# calculate the gray level - we are using typical weights here
put 0.30 * charToNum (char (tImgPosition + 2) of tImage) + \
0.59 * charToNum (char (tImgPosition + 3) of tImage) + \
0.11 * charToNum (char (tImgPosition + 4) of tImage) into tGray
# set the RGB of the pixel to the same value this gives us the gray level
## Her we decide if the resulting pixel will be balck or white!
if tGray >= tThreshold then
## White
put 255 into tGray
else
## Black
put 0 into tGray
end if
put numToChar (tGray) into char (tImgPosition + 2) of tImage
put numToChar (tGray) into char (tImgPosition + 3) of tImage
put numToChar (tGray) into char (tImgPosition + 4) of tImage
end repeat
##assign the updated image data back to the displayed image
set the imageData of image "Image" to tImage
set the cHiddenImageData of image "Image" to tImage
end mouseUp
Tested and works!
Hint:
This will not turn the image into a real B/W BITMAP image, it will only change the RGB values accordingly!
Best
Klaus