对图形进行对数变换

#include <iostream>  
#include <string.h>
#include <opencv2/core/core.hpp>  
#include <opencv2/highgui/highgui.hpp>  
#include <opencv2\core\mat.hpp>
#include<opencv2/opencv.hpp>
#define e 2.71828182845
using namespace cv;
using namespace std;

void main()
{
	Mat img = imread("pic2.jpg");//读取图像img。0表示转换为灰度图像读入
	imshow("原图", img);
	waitKey(0);
	int height = img.rows;
	int width = img.cols; 
	//浮点变换
	Mat fimg(height, width, CV_32FC3);
	img.convertTo(fimg, CV_32FC3,1/255.0);
	
	//将修改后的像素值放入另一个图片中
	Mat fimg2(height,width, CV_32FC3);
	for (int row = 0; row < height; row++)
		for (int col = 0; col < width; col++)
		{
			
			fimg2.at<Vec3f>(row, col)[0] = float(log(fimg.at<Vec3f>(row, col)[0])+1.0);
			fimg2.at<Vec3f>(row, col)[1] = float(log(fimg.at<Vec3f>(row, col)[1])+1.0);
			fimg2.at<Vec3f>(row, col)[2] = float(log(fimg.at<Vec3f>(row, col)[2])+1.0);
		}
	namedWindow("rgb", 0);
	imshow("rgb",fimg2);
	waitKey(0);
	//三通道进行输出
	for (int i = 0; i < 3; i++)

	{

		Mat bgr(height, width, CV_32FC3, Scalar(0, 0, 0));

		Mat out[] = { bgr };

		int from_to[] = { i, i };

		mixChannels(&fimg2, 1, out, 1, from_to, 1);

		//获得其中一个通道的数据进行分析
		imshow("1 channel", bgr);
		waitKey();

	}
}

 

 
 
G
M
T
 
 
Detect languageAfrikaansAlbanianAmharicArabicArmenianAzerbaijaniBasqueBelarusianBengaliBosnianBulgarianCatalanCebuanoChichewaChinese (Simplified)Chinese (Traditional)CorsicanCroatianCzechDanishDutchEnglishEsperantoEstonianFilipinoFinnishFrenchFrisianGalicianGeorgianGermanGreekGujaratiHaitian CreoleHausaHawaiianHebrewHindiHmongHungarianIcelandicIgboIndonesianIrishItalianJapaneseJavaneseKannadaKazakhKhmerKoreanKurdishKyrgyzLaoLatinLatvianLithuanianLuxembourgishMacedonianMalagasyMalayMalayalamMalteseMaoriMarathiMongolianMyanmar (Burmese)NepaliNorwegianPashtoPersianPolishPortuguesePunjabiRomanianRussianSamoanScots GaelicSerbianSesothoShonaSindhiSinhalaSlovakSlovenianSomaliSpanishSundaneseSwahiliSwedishTajikTamilTeluguThaiTurkishUkrainianUrduUzbekVietnameseWelshXhosaYiddishYorubaZulu
 
AfrikaansAlbanianAmharicArabicArmenianAzerbaijaniBasqueBelarusianBengaliBosnianBulgarianCatalanCebuanoChichewaChinese (Simplified)Chinese (Traditional)CorsicanCroatianCzechDanishDutchEnglishEsperantoEstonianFilipinoFinnishFrenchFrisianGalicianGeorgianGermanGreekGujaratiHaitian CreoleHausaHawaiianHebrewHindiHmongHungarianIcelandicIgboIndonesianIrishItalianJapaneseJavaneseKannadaKazakhKhmerKoreanKurdishKyrgyzLaoLatinLatvianLithuanianLuxembourgishMacedonianMalagasyMalayMalayalamMalteseMaoriMarathiMongolianMyanmar (Burmese)NepaliNorwegianPashtoPersianPolishPortuguesePunjabiRomanianRussianSamoanScots GaelicSerbianSesothoShonaSindhiSinhalaSlovakSlovenianSomaliSpanishSundaneseSwahiliSwedishTajikTamilTeluguThaiTurkishUkrainianUrduUzbekVietnameseWelshXhosaYiddishYorubaZulu
 
 
 
 
 
 
 
 
 
Text-to-speech function is limited to 200 characters
 
 
Options : History : Feedback : DonateClose
©️2020 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页