Image processing (image inversion, logarithmic transformation, power transformation, piecewise linear transformation)

Source: Internet
Author: User

1. Logarithmic transformation realizes the function of gray scale and compression of image. It expands the low gray value and compresses the high gray value, which makes the gray distribution of the image more conform to the human visual characteristics.

/******************************************************************************* function: Logarithmic transformation function * Parameter: pDst output    The pixel array of the image * Parameters: PSRC The original image's pixel array * parameters: nwidth Original image Width * parameter: nheight original image Height * parameter: A control parameter, indicating the upper and lower offset of the curve * Parameter: B control parameter, which indicates how curved the curve is. Note: This function is also suitable for color graphs ****************************************************************** ************/intLogtrans (byte* pDst, byte* PSRC,intNwidth,intNheight,DoubleADoubleBB) {    if(!PSRC | |!pDst) {        returnexit_failure; }    //mapping table for values after 256 grayscale transformationsBYTE map[ the]; //temporary values after saving an operation    Doubledtemp; intI, J;  for(i =0; I < the; i++)    {        //calculates the value after the current pixel transformDtemp = log (Double) i +1.0)/b +A; //If the bounds modify its value        if(Dtemp <0) Dtemp=0.0; Else if(Dtemp >255) Dtemp=255; //RoundingMap[i] =int(Dtemp +0.5); }     for(i =0; I < nwidth * nheight; i++)    {             for(j =0; J <4; J + +) Pdst[i*4+J] = map[psrc[i*4+J]]; }    returnexit_success;}

Image processing (image inversion, logarithmic transformation, power transformation, piecewise linear transformation)

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.