Photoshop Image processing algorithm implementation-brightness adjustment

Source: Internet
Author: User

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

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.