【问题标题】:Difference in image display (MATLAB and VISUAL STUDIO)图像显示的差异(MATLAB 和 VISUAL STUDIO)
【发布时间】: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 中尝试过,但它们都给了我不同的图像(对比度不同)(我只对 Laa 部分感兴趣>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


【解决方案1】:

很可能实际的像素强度值是相同的。

我的粗略猜测是,您观察到这种对比度差异的原因是您使用 imshow(C_a, []) 扩展了可视化强度范围。

试试普通的imshow(C_a) 看看你得到了什么。

【讨论】:

  • 我已经尝试过 imshow(C_a)。它会给我一个黑白图像。但是和visual studio给出的图片还是有区别的。(其实C_a加128就是把图片转换成8位格式我用这个转换公式来转换图片的[链接]docs.opencv.org/2.4/modules/imgproc/doc/…
【解决方案2】:

我确认这是因为显示函数 imshow(C_a, []) 拉伸了强度范围

请看

http://blogs.mathworks.com/steve/2016/03/21/matlab-image-display-autoscaling-values-with-imshow/

也出现在 MATLAB 文档中

以及为什么我会像这样在 Visual Studio/opencv 中获取图像; Lab转换功能将每个像素添加128,以便将图像范围转换为0-255(因为Lab颜色空间将具有负值)

【讨论】:

    猜你喜欢
    • 2017-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多