Preface: Some relevant methods of Photoshop color space used in the company to do the project, summarize here. The following principles are partially intercepted from my summary document. Need to copy the children's shoes to write their own ~
2. Program part
1) MATLAB Experiment program.
Clc;clear;close all;image=imread (' img_0950_cut.jpg '); figure (1); Imshow (Image); R=double (Image (:,:, 1)); G=double (Image (:,:, 2)); B=double (Image (:,:, 3)),% input adjustment parameter between value [-100,100], and Photoshop consistent value=-50;% to [-255,255] corresponds to the physical meaning of the value=value* 255/100;if (value>=0) r = r + (255-r) * value/255; g = g + (255-g) * value/255; B = B + (255-b) * Value/255;else r = r + R * value/255; g = g + G * value/255; B = B + b * VALUE/255;ENDIMG (:,:, 1) =uint8 (R); IMG (:,:, 2) =uint8 (G); IMG (:,:, 3) =uint8 (b); figure (2); Imshow (IMG);
2) C program, where only the key processing part, has turned the image into an array to deal with.
void Brightadjustrgb (unsigned char *psrc, unsigned char *pdest, int nwidth, int nheight,int nparameter) {//Parameter range validity judgment if (nPa Rameter <-100 | | Nparameter > return;//local variable declaration int i = 0; int t = 0;int nlength = nwidth * nheight;//Zoom adjustment parameter Nparameter = Nparame ter * 255/100;//Gets the result if (nparameter >= 0) {for (i = 0; i < nlength; i++) { T = i * 3; PDEST[T] = psrc[t] + (255-psrc[t]) * nparameter/255; Pdest[t + 1] = psrc[t + 1]+ (255-psrc[t + 1]) * NPARAMETER/255; Pdest[t + 2] = psrc[t + 2]+ (255-psrc[t + 2]) * nparameter/255; }} else{for (i = 0; i < nlength; i++) { T = i * 3; PDEST[T] = Psrc[t] + psrc[t] * nparameter/255; Pdest[t + 1] = psrc[t + 1] + psrc[t + 1] * nparameter/255; Pdest[t + 2] = psrc[t + 2] + psrc[t + 2] * nparameter/255;}}
3, experimental results, and Photoshop processing results consistent
Figure 1 Original
Figure 2 The parameter is-50 result
Figure 3 The parameter is 50 results
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Photoshop Image processing algorithm implementation-brightness adjustment