如何使用CImg从显示的图像中选择区域 [英] How to select an area from displayed image using CImg

查看:126
本文介绍了如何使用CImg从显示的图像中选择区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

这是我编写的一小段代码,是我在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;
 disp.assign(img);
 while(!disp.is_closed)
    disp.wait();
 return 0;  
}


这是我的问题:

我想从显示的图像中选择一个区域.有人可以告诉我如何从显示的图像中选择一个区域并存储选定的像素,然后在不同的显示窗口中显示选定的区域.如果有人可以提供代码,那将对我有很大帮助.

谢谢大家

解决方案

您尝试过 CImg论坛 [ ^ ]?

理查德,

你的小费确实帮助了我.非常感谢.
这是我发布的问题的答案:

#include "../CImg.h"
  5 #include <iostream>
  6
  7 using namespace std;
  8 using namespace cimg_library;
  9
 10 int main()
 11 {
 12     CImg <unsigned char > image("img/logo.bmp");
 13     CImgDisplay disp(image,"Input Image");
 14
 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
    ),SelectedImageCords(1),SelectedImageCords(3),SelectedImageCords(4));
 18
 19     CImgDisplay disp2(SelectedImage,"Selected Image");
 20     while(!disp3.is_closed)
 21         disp2.wait();
 22     return 0;
 23 }     



非常感谢Richard.


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;
 disp.assign(img);
 while(!disp.is_closed)
    disp.wait();
 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

解决方案

Did you try the CImg forums[^]?


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>
  6
  7 using namespace std;
  8 using namespace cimg_library;
  9
 10 int main()
 11 {
 12     CImg <unsigned char > image("img/logo.bmp");
 13     CImgDisplay disp(image,"Input Image");
 14
 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
    ),SelectedImageCords(1),SelectedImageCords(3),SelectedImageCords(4));
 18
 19     CImgDisplay disp2(SelectedImage,"Selected Image");
 20     while(!disp3.is_closed)
 21         disp2.wait();
 22     return 0;
 23 }     



Thank you very much richard.


这篇关于如何使用CImg从显示的图像中选择区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆