简体   繁体   中英

What is the MS Office contrast algorithm?

Does anyone know what formula MS Office uses to apply contrast adjustments to image?

It looks like the quadratic function, but I couldn't discover it.

Not too sure what formula they use. I doubt you'll find out either since nothings opensource but here is code I use for contrast adjustment:

function(im, contrast=10){
   # Get c-value from contrast
   c = (100.0 + contrast) / 100.0
   # Apply the contrast
   im = ((im-0.5)*c)+0.5
   # Cap anything that went outside the bounds of 0 or 1 
   im[im<0] = 0
   im[im>1] = 1
   # Return the image
   return(im)
}

This works really well for me.

Note

this assumes your pixel intensity values are on a scale of 0 to 1. If on a 255 scale, change lines im = ((im-0.5*255)*c)+0.5*255 and im[im>255] = 255

the function above is in R language

Good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM