⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grayscale.cpp

📁 基于小波的图像配准
💻 CPP
字号:
/* This procedure is for adjusting the value into 0-255
   source: duble array
   target: char array   
*/

#include "grayscale.h"

void grayscale(long xlen,long ylen,double* source,unsigned char* target)
{
	
	double max_v=source[0];
	double min_v=source[0],temp;
	long t=xlen*ylen;
	long i;
	for(i=0;i<t;i++)
	{
        if(max_v<source[i]) max_v=source[i];
		if (min_v>source[i]) min_v=source[i];
	}
	
  
		double l;
		l=max_v-min_v;
		
	    double grain=255/l;
		
		double offset=-(min_v*grain);
		
		for(i=0;i<t;i++)
		{
		    temp=grain*source[i]+offset;
			target[i]=(unsigned char)temp;
			//target[i]=(unsigned char)source[i]/2;
		}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -