Load a image and save that image in many color changers using javaCV

Today I will show you load a image and save that image in many color changers.
  1. Make a new java project and import the Open CV libraries
  2. If you don't know about it please follow the first post with javaCV
  3.  IplImage image =cvLoadImage("img.JPG");
  4. Make IplImage type variable it name is "image". "img.JPG" is assigned to to image.
  5. IplImage hsv=cvCreateImage(cvGetSize(image),IPL_DEPTH_8U,3);
    • make a HSV type image
    • cvcreateImage() need 3 parameters.
      1. size of image
      2. Type of image
      3. Nomber of frames in the image.
        • if it is 1 ,it is gray color image
        • if it is 3,it is colored image. 3 frames mean it have BGR(Blue,green,Red) frames.
        • if it is 4,it contain four frames. That mean it have BGR frames and alpha frame. Alpha is transparancy of image
  6. IplImage gray=cvCreateImage(cvGetSize(image),IPL_DEPTH_8U,1);
  7. make a gray colored image
cvCvtColor(image,hsv,CV_BGR2HSV);
Convert original image to a HSV image

  • cvCvtColor(image, gray, CV_BGR2GRAY);
  • convert original image to gray image
  • cvShowImage("Original",image);
  • Make a window to show original image. Window name is "original"
  • cvShowImage("HSV", hsv);
  • Make a window to show HSV image. Window name is "HSV"
  • cvShowImage("Gray", gray);
  • Make a window to show Gray image. Window name is "Gray".
  •         cvWaitKey();
            
            cvSaveImage("HSV.JPG",hsv);
  • Save the hsv image in jpg type. It name will be "HSV.JPG"
  • cvSaveImage("Gray.JPG",gray);
  • Save the gray image in jpg type. It name will be "Gray.PGP"
  •    
            cvReleaseImage(image);
            cvReleaseImage(hsv);
            cvReleaseImage(gray);
  • Release the memory allocated for image,hsv,gray variable we made.

     
    Type above codes. Then go to project folde and paste a image to src folde.

    Then go to your project folde. You can see that saved images.

    8 comments:

    1. Unfortunately, I can't program, but it has always been my dream. However, I like to use all kinds of applications that work in the cloud. Anyway, as I saw, the company https://www.grapeup.com makes very interesting native applications solutions.

      ReplyDelete