grayscale to monochrome

Discussion related to "under the hood" OpenMV topics.
pcls1026
Posts: 62
Joined: Tue Aug 22, 2017 1:33 am

grayscale to monochrome

Postby pcls1026 » Sun Mar 25, 2018 9:43 pm

Hi,
What this this command do? image.binary(thresholds(50, 255),invert=false)
Jim
User avatar
kwagyeman
Posts: 2286
Joined: Sun May 24, 2015 2:10 pm

Re: grayscale to monochrome

Postby kwagyeman » Sun Mar 25, 2018 9:50 pm

Hi, binary turns an image black and white
What are you trying to do?
Nyamekye,
pcls1026
Posts: 62
Joined: Tue Aug 22, 2017 1:33 am

Re: grayscale to monochrome

Postby pcls1026 » Sun Mar 25, 2018 9:59 pm

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
User avatar
kwagyeman
Posts: 2286
Joined: Sun May 24, 2015 2:10 pm

Re: grayscale to monochrome

Postby kwagyeman » Sun Mar 25, 2018 10:47 pm

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.
Nyamekye,
pcls1026
Posts: 62
Joined: Tue Aug 22, 2017 1:33 am

Re: grayscale to monochrome

Postby pcls1026 » Sun Mar 25, 2018 10:59 pm

my image that I load in is already grayscale. I want to convert the grayscale to black and white.
User avatar
kwagyeman
Posts: 2286
Joined: Sun May 24, 2015 2:10 pm

Re: grayscale to monochrome

Postby kwagyeman » Sun Mar 25, 2018 11:10 pm

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.
Nyamekye,
pcls1026
Posts: 62
Joined: Tue Aug 22, 2017 1:33 am

Re: grayscale to monochrome

Postby pcls1026 » Sun Mar 25, 2018 11:24 pm

how do i show it in the frame buffer so I can see it?
User avatar
kwagyeman
Posts: 2286
Joined: Sun May 24, 2015 2:10 pm

Re: grayscale to monochrome

Postby kwagyeman » Mon Mar 26, 2018 12:24 am

sensor.flush()

After everything.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests