【发布时间】:2016-05-29 04:43:56
【问题描述】:
for(i=0;i<m_bitmap.bmHeight-1; i++)
{
for(j=0; j<m_bitmap.bmWidth-1; j++)
{
r = GetRValue(imagearr1[i][j]);
g = GetGValue(imagearr1[i][j]);
b = GetBValue(imagearr1[i][j]);
temp_r = r/255.00;
temp_g = g/255.00;
temp_b = b/255.00;
/////////////////XYZ conversion////////////////
temp_X = (0.412453*temp_r + 0.357580*temp_g + 0.180423*temp_b);
temp_Y = (0.212671*temp_r + 0.715160*temp_g + 0.072169*temp_b);
temp_Z = (0.019334*temp_r + 0.119193*temp_g + 0.950227*temp_b);
///////////////Normalisation/////////////
X = temp_X/0.950456;
Y = temp_Y/1.00;
Z = temp_Z/1.088754;
if ( X > 0.008856 )
{
X = pow(X , (1.00/3.00) );
}
else
{
X = ( 7.787 * X ) + ( 16.00 / 116.00 );
}
if ( Y > 0.008856 )
{
Y = pow (Y , (1.00/3.00) );
}
else
{
Y = ( 7.787 * Y ) + ( 16.00 / 116.00 );
}
if ( Z > 0.008856 )
{
Z = pow (Z , (1.00/3.00) );
}
else
{
Z = ( 7.787 * Z ) + ( 16.00 / 116.00 );
}
C_L = ( 116.00 * Y ) - 16.00;
C_a = (500.00 * ( X - Y )+128);
C_b = 200.00 * ( Y - Z );
imagearr2[i][j] = RGB(C_a,C_a,C_a);
}
}
k=0;
for(i=m_bitmap.bmHeight-1; i>=0; i--)
{
for(j=0; j<m_bitmap.bmWidth; j++)
{
*(byte+k) = GetBValue(imagearr2[i][j]);
k++;
*(byte+k) = GetGValue(imagearr2[i][j]);
k++;
*(byte+k) = GetRValue(imagearr2[i][j]);
k++;
}
k=k+padding;
}
SetDIBitsToDevice(
m_hmainmemdc, 0, 0, m_bitmap.bmWidth, m_bitmap.bmHeight, 0, 0 , 0,
m_bitmap.bmHeight, byte, &bm,DIB_RGB_COLORS);
BitBlt(dc.m_hDC,0,0,rect.right,rect.bottom, m_hmainmemdc,0,0, SRCCOPY);
嗨,
我正在将图像(颜色)从 RGB 转换为 LAB 颜色空间并显示它。
我在 MATLAB 和 VISUAL STUDIO 中尝试过,但它们都给了我不同的图像(对比度不同)(我只对 La 的 a 部分感兴趣>b 图像)。
请查看我用来在 MATLAB 和 Visual Studio 中转换的代码。 我检查了这方面的精度错误,并了解两个编译器都给了我相同的数字。
我在 MATLAB 中使用了相同的公式和逻辑,但我没有在最终的 a 值中添加 128,为了显示它,我使用了这个命令
“imshow(C_a, [])”
我想在 MATLAB 中获得结果图像,我应该使用哪种类型的转换?
提前致谢!
Visual Studio
MATLAB
【问题讨论】:
-
对于你的matlab图像,
max(C_a(;))是什么,class(C_a)是什么? -
我希望这是你所问的(你写的函数在 matlab 中给我一个错误) max(max(C_a)) = 77.28 , min(min(a)) = -24.6582, class(C_a ) = 双倍。而且我还读到 imshow(C_a, [ ] ) 正在增加图像的动态范围,这可能是它背后的原因,在这种情况下,我需要 MATLAB 如何做到这一点?谢谢。
标签: matlab visual-studio-2012 image-processing