回到扫描线 [英] get back scanline

查看:83
本文介绍了回到扫描线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于数字图像处理的源代码.
在我的代码中,左上方有Scanline.我也要从右上角,左下角,右下角的方向扫描线.该怎么办呢?

I have a source code for digital image processing.
In my code there is Scanline from top left. I want also Scanline from direction top right, bottom left, bottom right. How can this be done?

private void button4_Click(object sender, EventArgs e)
        {
            // GDI+ still lies to us - the return format is BGR, NOT RGB.
            BitmapData bmData = RImage.LockBits(new Rectangle(0, 0, RImage.Width, RImage.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            int stride = bmData.Stride;
            System.IntPtr Scan0 = bmData.Scan0;

            unsafe
            {
                byte* p = (byte*)(void*)Scan0;

                int nOffset = stride - RImage.Width * 3;

                for (int y = 0; y < RImage.Height; ++y)
                {                   
                    for (int x = 0; x < RImage.Width; ++x)
                    {
                       
                        //supaya setiap y baru seed juga baru
                        if ((x == 0) || (seedR == 0))
                        {                            
                            //mengambil value seed
                            seedR = p[x];
                            seedG = p[x+1];
                            seedB = p[x+2];
                        }
                        else
                        {
                            if ((seedR - p[x] >= tred) || (p[x] - seedR >= tred))
                            {
                                for (int i = 0; i < 2; ++i)
                                {
                                    p[x] = p[x + 1] = p[x + 2] = 255;
                                    ++x;
                                }
                                                                    
                                seedR = 0;
                                seedG = 0;
                                seedB = 0;
                            }
                        }                        
                        
                        
                        p += 3;
                    }
                    p += nOffset;
                }
            }

            RImage.UnlockBits(bmData);
        }

推荐答案

您无法更改扫描线的方向".

重要的是,您永远不需要.

您应该了解,所有指针计算(我指的是代码示例)在调用UnlockBits之前都不会更改实际的位图数据,并且仅当您使用Graphics实际绘制位图时,位图数据才会显示在屏幕上对象.

您当然还有其他想法,但是您需要解释所需的应用程序.尽管如此,无论它是什么,扫描线都将以相同的方式工作.
You cannot change the "direction" of scan line.

Importantly, you never need to.

You should understand, that all you pointer calculation (I''m referring to your code sample) never change actual bitmap data until you call UnlockBits, and bitmap data goes to screen only when you actually draw your bitmap using your Graphics object.

You certainly have something else in mind, but you need to explain the application of what you want. Nevertheless, whatever it is, scan line will work the same way.


这篇关于回到扫描线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆