GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 20-Jun-2012, 09:05
stbb24 stbb24 is offline
New Member
 
Join Date: May 2012
Posts: 14
stbb24 is on a distinguished road

Binary Image Issue


I convert a color image into binary with this line of code

Code:
cvtColor(img, src_gray, CV_RGB2GRAY); threshold(src_gray, dst, minThres, maxThres, CV_THRESH_BINARY);

where minThresis 0 and maxThres 1

The output is a black image

My question is since the resulting image is pure black.
Can it still be considered binary? (I just want to make sure)

The reason why I'm asking is because I need a binary image with pixel values of 0's and 1's and since the resulting image (which is a black image) already has the values that I want (i checked the values).

I guess I just want to verify if having a binary image with pixel values of 1's and 0's will always result in a black image

  #2  
Old 20-Jun-2012, 10:23
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 6,147
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Binary Image Issue


Quote:
Originally Posted by stbb24
Code:
cvtColor(img, src_gray, CV_RGB2GRAY); threshold(src_gray, dst, minThres, maxThres, CV_THRESH_BINARY);
where minThres is 0 and maxThres 1
So: from the grayscale image, every pixel that has a value of zero appears with a value of zero in the dst image. Every pixel in the grayscale image whose value is not zero appears with a value of 1 in the dst image.
Quote:
Originally Posted by stbb24

The output is a black image
Huh? Since you have observed that it has pixel values of 0 and 1, it is not a black image; it is a binary image with two different values of pixels: 0 and 1. (See Footnote.)

Quote:
Originally Posted by stbb24
I just want to verify if having a binary image with pixel values of 1's and 0's will always result in a black image.
That makes no sense at all (to me).
It is not a black image; it is a binary image with two different values of pixels: 0 and 1. (But I said that already).

Now on a scale from 0 through 255, a single pixel with a value of 1 (very, very, very dark gray) may be practically indistinguishable from a single pixel with a value of 0 (pure black), or, maybe not.

Whether there is a humanly perceptible difference between your dst image and a pure black image depends on the quality of the monitor (or printer) and room lighting and the visual acuity of the human observer and whether there are large areas of pure black in the middle of large areas of very, very, very dark gray (or vice-versa).

Bottom line: If you are processing the image mathematically, there may be a lot of practical difference between a black image and a binary image with pixel values 0 and 1 (depending on the nature of the mathematical treatment). On the other hand, if you are just looking at the image, well, maybe not so much...




Regards,

Dave

Footnote:
If it just happened that there were no pixels in the grayscale image whose value was zero, then all pixels in the dst image would have had values of 1. It wouldn't be a black picture; it would be a solid very, very, very dark gray picture.

If it just happened that all pixels in the in the grayscale had values equal to zero, then all pixels in the dst image would have had values of zero. Then the dst image would be a solid black picture.
__________________
Sometimes I just can't help myself...
  #3  
Old 20-Jun-2012, 20:50
stbb24 stbb24 is offline
New Member
 
Join Date: May 2012
Posts: 14
stbb24 is on a distinguished road

Re: Binary Image Issue


Quote:
The output is a black image
when I said the output is a black image I'm just saying base from what I saw "black image" but mathematically speaking it is a binary image with 1's and 0's

Thanks again for your comments
 
 

Recent GIDBlogMatch IP in CIDR by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Second Image to Binary using OpenCv stbb24 C++ Forum 2 02-Jun-2012 00:58
How do I execute a function in a switch statement? kkmoslehpour C Programming Language 15 17-Oct-2011 10:06
Problem with updating itk image in Qt user interface Angobar C++ Forum 0 12-Sep-2011 06:33
Reading and writing binary files in certain format Dream86 C++ Forum 10 06-Aug-2004 10:38
Google Adsense introduces targetted image ads Div Advertising & Affiliates Forum 5 23-May-2004 10:59

Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 21:35.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.