Click here to Skip to main content
15,878,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I using visual studio 2010 and open CV library , in C language
my question is how I ca transform image pgm to pbm for example after put like *file and read the image only in binary 0 or 1 ?
thnk u

What I have tried:

this to convert image to greyscale
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "iostream"

using namespace cv;
using namespace std;

int main( )
{

Mat image;
image = imread("lena.jpg", CV_LOAD_IMAGE_COLOR);

if(! image.data )
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}

// Create a new matrix to hold the gray image
Mat gray;

// convert RGB image to gray
cvtColor(image, gray, CV_BGR2GRAY);

namedWindow( "Display window", CV_WINDOW_AUTOSIZE );
imshow( "Display window", image );

namedWindow( "Result window", CV_WINDOW_AUTOSIZE );
imshow( "Result window", gray );

waitKey(0);
return 0;
}
Posted
Updated 11-Jun-16 3:59am
Comments
Patrice T 11-Jun-16 9:24am    
A problem in this code ?
yagami_md 11-Jun-16 9:35am    
I know how I can convert to greyscale but I want know ow I an convert to binary pbm? and thnk sir

1 solution

If you search a little you will find answers like this:

c++ - Convert RGB to Black &amp; White in OpenCV - Stack Overflow[^]
 
Share this answer
 
Comments
yagami_md 11-Jun-16 10:46am    
oki thnx , I will try this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900