Let's give you a detailed analysis of the various methods for converting color images to grayscale.Tutorial sharing:Method 1: convert menus to grayscaleThis may be the quickest, at least the most common method. Select a file and select "edit-edit color-convert to grayscale ".Click "next page". Let's take a look at the following method.
and V is 0-1.Second, use the function of OPENCV to convert color image to grayscale Image:#includeusing namespace CV;using namespace Std;int main (){Mat src = imread ("lena.jpg", 1);Mat src = imread ("Lena.jpg", 0);Mat DST;Namedwindow ("RGB", window_autosize);Imshow ("RGB", SRC);Waitkey (0);Cvtcolor (Src,dst,cv_bgr2gray);Namedwindow ("GRAY", window_autosize);Imshow ("GRAY", DST);CoutWaitkey (0);Src.release
There are several ways we can convert it to grayscale: 1. Floating-point algorithm: gray=r*0.3+g*0.59+b*0.112. Integer method: gray= (r*30+g*59+b*11)/1003. Shift Method: Gray = (r*76+g*151+b* >>8;4. Average method: gray= (r+g+b)/3;5. Green only: gray=g;DOCTYPE HTML>HTMLLang= "en">Head> MetaCharSet= "UTF-8"> title>Graytitle>Head>Body> CanvasID= ' MyCanvas 'width= ' + 'Height= ' + '>your browser does
CPUVoid cpu_histgo (){Int I, J;For (I = 0; I {For (j = 0; j {// Printf ("data: % d \ n", data [I * width + J]);Hostbin [DATA [I * width + J] ++;// Printf ("hostbin % d = % d \ n", data [I * width + J], hostbin [DATA [I * width + J]);}}}
How to Use opencl to calculate grayscale images is not that easy. We know that the advantage of GPU is parallel computing. How to partition images to calculate histograms in parallel is the focus of our discussion. Th
Converts a color RGB image to a grayscale image, where the pixel value is converted to
Grayscale Value =0.2989 * R + 0.5870 * G + 0.1140 * B
The original color RGB image is a three-channel, converted into a single-channel grayscale image
You wrote a Python program that implements the conversion task:
#-*-Coding:utf-8-*-
#
rgb2greyBtn to the "convert to grayscale" button. setOnClickListener (new OnClickListener () {@ Override public void onClick (View v) {// TODO Auto-generated method stub // display the converted grayscale image imageView2.setImageBitmap (convertGreyImg (bitmap ));}});} /*** convert a color image to a
Turn a color picture into grayscale;////////////////////////////#include There are two main ways to convert color images to grayscale, one is to convert directly from the Cvcvtcolor function of OpenCV, and the other is to process pixels directly.OPRENCV Learning Road One: converting color images to
1. convert a single image to a grayscale image
Convert image.png-colorspace gray image-gray.png.
2. batch conversion
Mkdir out
Note: The preceding commands must be run in the DOS environment. You must install ImageMagick before using the convert command. I like to use its portable version. After decompression, I c
Reference: http://blog.csdn.net/cool1949/article/details/6649429 RGB image to grayscale image
Today in helping Li Na classmate read the code, suddenly thought of to scrutiny RGB image conversion to grayscale image principle. So began the story of this blog. As a little white, the elaboration may not be very specific and comprehensive. I hope that we could make progress together.In general, the RGB image is
#include "stdafx.h"//implement to convert a color picture to a grayscale imageint _tmain (int argc, _tchar* argv[]){Iplimage *image; Initialize Save original imageIplimage *result; Save Grayscale imageImage = Cvloadimage ("Picture 3.jpg",-1);int channel =-1;int depth =image->depth;Cvsize sz;Sz.width =image->width;Sz.height =image->height;result = Cvcreateimage (S
What is a grayscale map? Any color has red, green, blue three primary colors, if the original point of the color of RGB (R,G,B), then, we can use the following methods to convert it to grayscale:
1. Floating-point algorithm: gray=r*0.3+g*0.59+b*0.11
2. Integer method: gray= (r*30+g*59+b*11)/100
3. Shift Method: Gray = (r*76+g*151+b*28) >>8;
4. Average method:
Extended image content processor: grayscale transformation and processor parameter problems
You want to extend the image processor to process the color of each independent pixel. You also want to change the processor parameters from the XNA main project.Solution
In the previous tutorial, you learned how to extend the content processor so that you can process and change the value of an independent pixel.
All public variables declared in the Processor c
Grayscale mode : Simple point that grayscale mode is like Black-and-white photos, all colors are in different 256 shades of gray (so in grayscale mode to fill in other color color, the default will be associated with the gray color replacement fill!)
indexing mode : When doing Web pages, indexed color files are generally GIF format (saved in GIF format of the pi
The first to learn to do the Web page, it is not careful to use the CMYK model of the picture, and then open in the browser is x, and then find a long time to know the original page to use RGB mode, now we have to simple Photoshop grayscale, index, RGB, CMYK four mode.
Grayscale mode : Simple point that grayscale mode is like Black-and-white photos, all colors
. The color displayed using the found value is true, but not the color of the image itself because it does not fully reflect the color of the original, so it is called a pseudo-color.The blending color is transformed by the r,g,b component of each pixel as a separate index value, and the corresponding color lookup table is used to find the intensity of the primary color, and the color is produced by the transformed R,g,b intensity value.Two. Introduction to
24-bit color graphs and 8-bit gray scale graphs
First of all, introduce 24-bit color image, in a 24-bit color image, each pixel is represented by three bytes, usually represented as RGB. Typically, many 24-bit color images are stored as 32-bit images, and each pixel's excess bytes are stored as a alpha value, with a special effect on the message [1].
In the RGB model, if r=g=b, then color represents a grayscale color, where the value of r=g=b is cal
1, first load the original picture;2, Cvcvtcolor (IMG, source, Cv_bgr2gray), convert to grayscale image;3, Cvthreshold (source,source_gray,100,255,cv_thresh_binary), binary processing.Since the original picture will have a certain angle, need to rotate, and the rotation can use the function provided by OPENCV, this article is written by itself, that is, by rotating 360, and record the rotation of an angle t
There are three ways to convert an image from a color graph to a grayscale mapThe weighted method of mean value method is the maximum value method, respectively!The weighted method is Gray==0.3*r+0.59*g+0.11*bThe mean method is gray== (R+G+B)/3Max value is max (R,G,B)A=imread (' D:\lena. BMP ');R=double (A (:,:, 1));G=double (A (:,:, 2));B=double (A (:,:, 3));[M,n]=size (R);Bw=zeros (M,n);Bw=0.3.*r+0.59.*g+
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.