|
Editing pixels in the image from Australia [87 posts] |
16 year
|
I would like to use pixel data from one image (marker A) to edit pixels in the second image (marker B). e.g. if pixel (200, 300) in marker A is below 100, then pixel (200, 300) in marker is set to 0.
1) In VBScript I can get the pixel data, but don't know how to differentiate where the pixel data is sourced from (e.g. marker A, current, ...).
Dim pixels
pixels = GetPixels()
index_location = (3*800 * y_coord) + (3 * x_coord)
value = pixels(index_location)
2) How can I edit the pixel data so to change the image?
I understand that it is a bit of a complicated one.
Cheers,
Nemanya
|
|
|
Anonymous |
16 year
|
Nemanya,
There are several ways to do this but you have to think in terms of one image at a time. Can you transform the current image into a mask that you then apply into the second one?
If you are looking to do this in VBScript (very slow but possible) then you will have to create a new image to set back to the current image. I.e. the following should do that.
pixels = GetPixels()
for i=0 to ubound(pixels) step 3
val = (pixels(i)+pixels(i+1)+pixels(i+2))/3
if val < 100 then
pixels(i) = 0
pixels(i+1) = 0
pixels(i+2) = 0
else
pixels(i) = 255
pixels(i+1) = 255
pixels(i+2) = 255
end if
next
which creates a black and white mask that can be used to zero or preserve the pixels in the second image when this now current image is used with either the math (and function) or mask module.
We're looking into a more general expression routine that will run much faster against images where you would be able to create this same mask but at near frame rate speeds. Be sure to use a small image in the above otherwise things will take minutes to run!
STeven.
|
|
|
from Australia [87 posts] |
16 year
|
Thanks STeven,
The Mask idea is much better, and it works
Cheers,
Nemanya
|
|