回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在开发基于微软论文<a href="https://www.microsoft.com/en-us/research/uploads/prod/2016/11/Digital-Signal-Processing.pdf" rel="nofollow noreferrer">Whiteboard scanning and image enhancement</a>的自动图像增强</p>
<p>在“白平衡和图像增强”部分,他们提供了增强的步骤:</p>
<p><strong>首先:他们估计扫描文档或检测到的白板的背景:</strong></p>
<blockquote>
<p><strong>1.</strong> "Divide the whiteboard region into rectangular cells. The cell size should be roughly the same as what we expect
the size of a single character on the board (15 by 15 pixels in our implementation)."</p>
</blockquote>
<p>那么</p>
<blockquote>
<p><strong>2.</strong> "Sort the pixels in each cell by their luminance values. Since the ink absorbs the incident light, the luminance of
the whiteboard pixels is higher than stroke pixels’. The whiteboard color within the cell is, therefore, the color with
the highest luminance. In practice, we average the colors of the pixels in the top 25 percentile in order to reduce
the error introduced by sensor noise"</p>
</blockquote>
<p>那么</p>
<blockquote>
<p><strong>3.</strong> "Filter the colors of the cells by locally fitting a plane in the RGB space. Occasionally there are cells that are
entirely covered by pen strokes, the cell color computed in Step 2 is consequently incorrect. Those colors are
rejected as outliers by the locally fitted plane and are replaced by the interpolated values from its neighbors."</p>
</blockquote>
<p>我的问题是第二步和第三步:</p>
<p><strong>如何获得亮度值,我应该将输入图像转换为YUV颜色空间,并从Y通道获得亮度值,还是只处理RGB颜色空间?</strong></p>
<p><strong>如何在RGB空间中拟合局部平面?</strong></p>
<p>这是我的python代码,我试图从输入图像生成单元格,从YUV颜色空间中获取亮度值,以及一个简单的结果,与他们在论文中得到的结果相比似乎不正确。</p>
<p><strong>Python代码:</strong></p>
<pre><code>import cv2
import numpy as np
## Return List of cells from a given Image
def SubImage(image):
Cells = []
CellRows = []
for i in range(0,rows/CellSize):
subIm = image[i*CellSize:(i+1)*CellSize,:]
CellRows.<a href="https://www.cnpython.com/list/append" class="inner-link">append</a>(subIm)
for img in CellRows:
for i in range(0,cols/CellSize):
subIm = img[:,i*CellSize:(i+1)*CellSize]
Cells.append(subIm)
return Cells
## Sort luminosity Value
def GetLuminance(Cells):
luminance = []
for cel in Cells:
luminance.append(cel.max())
return luminance
## Estimate the background color of the white board
def UniformBackground(CelImage,img,luminance):
a = 0
for c in range(0,len(CelImage)):
cel = CelImage[c]
for i in range(0,cel.shape[0]):
for j in range(0, cel.shape[1]):
cel[i,j] = min(1,cel[i,j]/ luminance[c])
for i in range(0,rows/CellSize):
for j in range(0,cols/CellSize):
img[i*CellSize:(i+1)*CellSize,j*CellSize:(j+1)*CellSize] = CelImage[a]
a = a + 1
if __name__ == '__main__':
img = cv2.imread('4.png')
CellSize = 15
rows,cols,depth = img.shape
if (rows%CellSize !=0):
rows = rows - rows%CellSize
if (cols%CellSize !=0):
cols = cols - cols%CellSize
yuvImg = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)
# Get cells from Y channel
CellsY = SubImage(yuvImg[:,:,0])
CellsB = SubImage(img[:,:,0])
CellsG = SubImage(img[:,:,1])
CellsR = SubImage(img[:,:,2])
# Get Luminance From Y cells
LuminanceY = GetLuminance(CellsY)
# Uniform Background
UniformBackground(CellsB, img[:,:,0], LuminanceY)
UniformBackground(CellsG, img[:,:,1], LuminanceY)
UniformBackground(CellsR,img[:,:,2], LuminanceY)
#bgrImg = cv2.cvtColor(imgB, cv2.COLOR_GRAY2BGR)
#print imgB
cv2.imwrite('unifrom.jpg',img)
</code></pre>
<p><strong>输入白板图像:</strong></p>
<p><a href="https://i.stack.imgur.com/rlzWx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rlzWx.png" alt="white Board image"/></a></p>
<p><strong>输出图像:</strong></p>
<p><a href="https://i.stack.imgur.com/U2VFS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U2VFS.jpg" alt="Output image"/></a></p>
<p><strong>预期输出:</strong></p>
<p><a href="https://i.stack.imgur.com/VLq5B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VLq5B.png" alt="expected Output"/></a></p>