Images of different grayscale levels

Source: Internet
Author: User

Study Dip No. 0 Day

For more details, refer to: http://tony4ai.com/2014/11/06/dip-1-1-images of different grayscale levels

Conclusion: For more detailed images, when the image size (N) is constant, the gray level is relatively independent of the sensory quality;

Explanation: If the image detail is more, lower the gray level, the visual feeling is not very different

Code writing is arbitrary and performance optimizations are not performed. Only for observation effect:

#define K 1//Grayscale level
#define STEP (256/(1<<k))
int main () {
	//char name[50];
	Iplimage * image = Cvloadimage ("E:\\opencv_image\\airplane.jpg", 0);
	Iplimage * result = Cvcreateimage (cvgetsize (image), 8,1);
	Cvnamedwindow ("original");
	Cvnamedwindow ("transform");
	Cvshowimage ("original", image);
	for (int i=0;i<image->width;i++) for
		(int j=0;j<image->height;j++) {
			int value=cvgetreal2d ( IMAGE,I,J);
			int step=step;
			while (value>step) {
				step+=step;	
			}
			Value=step;
			cvsetreal2d (Image,i,j,value);
		}
	Cvshowimage ("transform", image);
	sprintf (name, "%s%d%s", "E:\\opencv_image\\airplane_", K, ". jpg");
	Cvsaveimage (name,image);
	Cvwaitkey ();
	Cvreleaseimage (&image);
	return 0;
	
}




Above three pictures from left to right from top to bottom, respectively: Original image, k=1,2,3,4,5,6,7,8 (1-order two-valued image, 8-order image grayscale)

Question: How much does a picture in the same resolution evaluate its details ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.