問題描述
什麼是 MS Office 對比算法? (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.
‑‑‑‑‑
參考解法
方法 1:
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
(by Dumka、Omar Wagih)