Click here to Skip to main content
15,939,243 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

This is small piece of code written by me as a start up for my image processing work in C++.
#include "../CImg.h"
#include <iostream> 
using namespace std;
using namespace cimg_library;
int main(int argc,char**argv)
 CImg<int> img(argv[1]);
 CImgDisplay disp;
 return 0;  

Here is my question:

I want to select an area from the displayed image. Can someone tell me how to select an area from displayed image and store the selected pixels, and display the selected region in different display window. If someone can provide code, it will be of great help to me.

Thank you all
Updated 2-Feb-10 11:31am

Did you try the CImg forums[^]?
Share this answer
hi Richard,

Your tip did help me. Thanks a lot.
Here is the answer for the question which i had posted:

#include "../CImg.h"
  5 #include <iostream>
  7 using namespace std;
  8 using namespace cimg_library;
 10 int main()
 11 {
 12     CImg <unsigned char > image("img/logo.bmp");
 13     CImgDisplay disp(image,"Input Image");
 15     cout<<"Select an area from the displayed image"<<endl;
 16     CImg <int> SelectedImageCords = image.get_select(disp,2,0,0);
 17     CImg <unsigned char> SelectedImage = image.get_crop(SelectedImageCords(0
 19     CImgDisplay disp2(SelectedImage,"Selected Image");
 20     while(!disp3.is_closed)
 21         disp2.wait();
 22     return 0;
 23 }     

Thank you very much richard.
Share this answer

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