实验八

#include <cv.h>
#include <highgui.h> //图像视频输出/输入头文件
int main()
{
    IplImage * test;
        IplImage * test_1;
    test = cvLoadImage("6013202130.bmp",0);//图片路径是 ConsoleApplication4 文件夹里,同时实验要求转为灰度图片
    test_1 = cvCreateImage(cvSize((test->width), (test->height)), IPL_DEPTH_8U, 1); //创建图像,给指针赋值
    CvScalar s;
    for (int i = 0; i < test->height; i++)
    {
         for (int j = 0; j < test->width; j++)
          {
             s = cvGet2D(test, i, j);
             s.val[0] = 32 * log10(s.val[0]) / log10(2.0);
             cvSet2D(test_1, i, j, s);

          }
    }

    cvNamedWindow("原图—6013202130", CV_WINDOW_AUTOSIZE);
    cvShowImage("原图—6013202130", test);
    cvNamedWindow("对数变换—6013202130", CV_WINDOW_AUTOSIZE);
    cvShowImage("对数变换—6013202130", test_1);
    cvWaitKey(0);//等待按键
    cvDestroyWindow("原图—6013202130");
    cvDestroyWindow("对数变换—6013202130");
    cvReleaseImage(&test);//释放内存。 
    cvReleaseImage(&test_1);
    return 0;
}

8.  对一幅灰度图像进行灰度对数变换。观察变换前后高、低灰度位置的变化并解释原因。

相关文章:

  • 2021-11-16
  • 2021-11-27
  • 2021-05-22
  • 2022-12-23
  • 2021-09-22
  • 2021-06-24
  • 2021-04-30
猜你喜欢
  • 2021-09-04
  • 2021-05-30
  • 2021-12-20
  • 2021-05-27
  • 2021-10-12
  • 2021-09-12
相关资源
相似解决方案