Dear community,
I wonder how to read out the pixel value of an image in xpce. I’m using SWI-Prolog version 7.2.2.
For a one-bit encoded bitmap this works (reading out pixel value at pixel position 20,20):
view1 :-
Xpos = 20,
Ypos = 20,
new(P, picture),
new(I, image('C:/test1.bmp')),
new(Bmp, bitmap(I)),
get(I, pixel, Xpos , Ypos, Value),
write(Value),
send(P, display ,Bmp),
send(P, open).
So I get either @on or @off, depending on the pixel, bitmap is displayed correctly.
But if I open an 8-bit gray valued bitmap:
view2 :-
Xpos = 20,
Ypos = 20,
new(P, picture),
new(I, image('C:/baboon8bit.bmp')),
new(Bmp, bitmap(I)),
get(I, pixel, Xpos , Ypos, Value),
write(Value),
send(P, display, Bmp),
send(P, open).
Prolog returns false.
Without the get-method (get-clause) the image is displayed correctly.
Other ways I tried:
get(I, pixel(20,20), Value), % --> false.
get(I, pixel(20,20), R,G,B ), % --> Type error.
get(I , pixel, 20,20, colour(Red,Yellow,Blue)), % --> false.
get(I , pixel, 20,20, colour(@default,Red,Yellow,Blue)), % --> false.
Reading out size, depth and kind (bitmap | pixmap) works for both images.
Is there a correct way to get the pixel values?
Thanks, Tobi