Absrtact: In the digital image, the other format images are generally converted into grayscale images so that the subsequent images are less computational.
Platform: windows10+ccs5.5+tms320dm642
Realize:
/* ======================================================================== *//* Copyright 2006 by Wintech Digital System Technology Corp. *//* All rights reserved. property of Texas Instruments Incorporated. *//* Restricted rights to use, duplicate or disclose this code is *//* granted through contract. *//* ======================================================================== *//*======== Header file Reference ===========*/#include "stdio.h"/*============= working variable definition ======*/unsigned char *pr_r; Pointer definition unsigned char *pr_g; Pointer definition unsigned char *pr_b; Pointer definition unsigned char *gray; Pointer definition//Description: Defines the data storage variable #pragma data_section (rgb_img, "data"); int rgb_img[40000]; #pragma data_section (r_img, "DATA") unsigned char r_img[20000]; #pragma data_section (g_im G, "data"); unsigned char g_img[20000]; #pragma data_section (b_img, "data"); unsigned char b_img[20000]; #pragma Data_section (gray_img, "data"); Unsigned Char gray_img[20000];void rgb2gray ();/////////////////////////////////////////////////////////////////////// Instructions for use://1. This procedure can move under simulator;//2. After the program compiles, links, loads successfully, first//execute file/data/load, the image data that will be color converted from Rgb_peppers96x128.dat//(Description: *.dat format, internal storage of an image each pixel RGB color value) loaded into the data memory Storage address rgb_img in//3. After the data has been loaded successfully, Debug/go Main, step-by-step running the program//////////////////////////////////////////////////////////////////////////////// *================= Main program ================*/main () {int N,FLG,IMGH,IMGW; int *ptr;/*=========== Initialize ==========*/flg=3; Used to select the Grayscale method imgh=96; Image height and width, because the data file corresponds to the image height and width is 96,128imgw=128; The pointer points to the array pr_r=r_img;pr_g=g_img;pr_b=b_img; gray=gray_img; 1 The data of RGB three channels are put into corresponding array ptr=rgb_img; for (n=0;ngray[i]) gray[i]= (unsigned char) g[i]; if (b[i]> Gray[i]) gray[i]= (unsigned char) b[i]; }}}/* ======================================================================== *//* Copyright (c) LDX Dig Ital System Technology Corp. *//* All rights Reserved. *//* ======================================================================== */
Import Data TOOL->load Memory
View Original Tools->image Analyzer
Original Configuration
Original effect
Post-processing diagram configuration
Effect of the post-processing diagram
Conversion of a color image into gray image algorithm in tms320dm642