Page 1 of 1

grayscale to monochrome

Posted: Sun Mar 25, 2018 9:43 pm
by pcls1026
Hi,
What this this command do? image.binary(thresholds(50, 255),invert=false)
Jim

Re: grayscale to monochrome

Posted: Sun Mar 25, 2018 9:50 pm
by kwagyeman
Hi, binary turns an image black and white
What are you trying to do?

Re: grayscale to monochrome

Posted: Sun Mar 25, 2018 9:59 pm
by pcls1026
I am loading a saved file using image.Image---
I want to convert the image to monochrome.
I want to have the monochrome image show in the IDE frame buffer.
Jim

Re: grayscale to monochrome

Posted: Sun Mar 25, 2018 10:47 pm
by kwagyeman
A grayscale image or a binary image?

Conversion from RGB565 to grayscale is not available right now. I'm working on increasing the firmware's ability however. In particular, adding lots of stuff like for this for the next version. I'll put this on my to-do queue.

Anyway, binary just produces a black and white image.

...

Alternatively, if you don't mind speed issues. You have pixel level access of images. You can manually convert colors yourself. Just grab a pixel, use the RGB to yuv method to a yuv value, set the u and v parts to 0 and then convert back to RGB.

Re: grayscale to monochrome

Posted: Sun Mar 25, 2018 10:59 pm
by pcls1026
my image that I load in is already grayscale. I want to convert the grayscale to black and white.

Re: grayscale to monochrome

Posted: Sun Mar 25, 2018 11:10 pm
by kwagyeman
Oh, then binary() is the method to use.

If you'd like for the camera to automatically pick the best threshold do:

value = img.get_histogram().get_threshold().value()
img.binary([(0, value)])

This uses otsu's method to pick the most pleasing threshold.

Re: grayscale to monochrome

Posted: Sun Mar 25, 2018 11:24 pm
by pcls1026
how do i show it in the frame buffer so I can see it?

Re: grayscale to monochrome

Posted: Mon Mar 26, 2018 12:24 am
by kwagyeman
sensor.flush()

After everything.