3月 162013
 

Your ads will be inserted here by

Easy AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

参考opencv示例

http://www.opencv.org.cn/index.php/%E5%9B%BE%E5%83%8F%E5%88%9B%E5%BB%BA%E3%80%81%E4%BF%9D%E5%AD%98%E5%92%8C%E5%A4%8D%E5%88%B6

public class test { 
public static void main(String args[]){ 
    IplImage image = cvLoadImage("lena.jpg");
    if(image==null)
    {
        System.err.print("Can not open file!\n");
        System.exit(1); 
    }

    IplImage pImg2 = cvCreateImage(cvGetSize(image),
    image.depth(),
    image.nChannels());
    cvCopy(image, pImg2, null);
    cvSaveImage("lena2.jpg", pImg2);//把图像写入文件 

    cvNamedWindow("Example",CV_WINDOW_AUTOSIZE); 
    //在窗口Example中显示图片
    cvShowImage("Example",image); 
    //暂停程序,等待用户触发一个按键
    cvWaitKey(0); 
    //释放图像所分配的内存 
    cvReleaseImage(image); 
    cvReleaseImage(pImg2); 
    //销毁窗口 
    cvDestroyWindow("Example"); 
    } 

}

首先保证当前工作目录下有图片文件,运行程序后
1、使用cvCopy(image, pImg2, null);来拷贝图片
2、使用cvSaveImage(“lena2.jpg”, pImg2);来保存图片
3、释放图片。
cvReleaseImage(image);
cvReleaseImage(pImg2);

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)