-4

I am using C to run a phase retrieval algorithm on images. I am using ImageJ to convert the .png into a text image that I then read into my code and run the code.

At the end I have printed the output to a text array, and then have to read it from imageJ as a text image.

I was wondering if there is a way to get an image straight from c?

Chris U
  • 53
  • 6

1 Answers1

0

You could try to use OpenCv, an Open source library of programming functions for computer vision tasks.

It could read and write on diferent image file formats using imread and imwrite functions, as you could see on this example from OpenCv's documentation web site:

#include <cv.h>
#include <highgui.h>

using namespace cv;

int main( int argc, char** argv )
{
 char* imageName = argv[1];

 Mat image;
 image = imread( imageName, 1 );

 if( argc != 2 || !image.data )
 {
   printf( " No image data \n " );
   return -1;
 }

 Mat gray_image;
 cvtColor( image, gray_image, CV_BGR2GRAY );

 imwrite( "../../images/Gray_Image.jpg", gray_image );

 namedWindow( imageName, CV_WINDOW_AUTOSIZE );
 namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );

 imshow( imageName, image );
 imshow( "Gray image", gray_image );

 waitKey(0);

 return 0;
}

Hope it helps!

  • Welcome to Stackoverflow. Would you mind extending your answer little bit more. Since the reference link added might not exist in future. – Nagama Inamdar Oct 23 '15 at 11:29