从图像获取边缘像素 [英] Getting the edge pixels from the image

查看:86
本文介绍了从图像获取边缘像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想知道任何允许我将图像的边缘像素(图像中对象的边缘)写入文本文件的算法.我想将这种算法用于我的隐身应用程序.

即,我想从背景中提取对象边缘.

试试这个链接:我不知道如何给确切的电话打电话
http://www.cogs.susx.ac.uk/users/davidy/teachvision/vision3_include/fig17.gif

Hi,
I would like to know any algorithm which will allow me to write the edge pixels(edges of the object in the image) from an image into a text file. I want this algorithm for my stego application.

ie, i want to extract the objects edge from the background.

try this link: i dont knw how to tel the exact requirement
http://www.cogs.susx.ac.uk/users/davidy/teachvision/vision3_include/fig17.gif

推荐答案



在c#中,您会看到类似波纹管的东西,我个人会编写一个Xaml文件,这样您就可以将标签用于Red Green Blue.遍历映像是唯一的选择,因为您获取像素数据,所以不要写入,因为这会减慢程序的速度,因为写入光盘的速度相对较慢.

如果您希望将各点分开,则可以始终使用4个列表,分别用于顶部,底部,左侧和右侧.或者,位置[0到(myImage.Width-1)]将位于顶部. [(myImage.Width-1)到(myImage.Width-1)+(myImage.Width-1)]将位于底部,依此类推...

Hi,

In c# your looking at something like bellow, personally I would write a Xaml file as then you could use tags for Red Green Blue. Looping through the image is the only option do not write as you get the pixel data as this will slow your program down since writing to your disc is relatively slow.

You could always use 4 lists one for top, bottom, left and right if you wish to keep the points separate. Alternatively positions [0 to (myImage.Width-1)] will be the top. [(myImage.Width-1) to (myImage.Width-1)+(myImage.Width-1)] will be the bottom and so on...

Bitmap my_new_image = new Bitmap(original_image.Width,  original_image.Height);

List<color> my_colour_list = new List<colour>(); //somewhere to store the info as writing the information will take a long time programmatically speaking as your accessing hard drive 

//Top
for (int x = 0; x < myImage.Width; x++)
{
   my_colour_list.Add(output_data.GetPixel(x, 0))    
}

//bottom
for (int x = 0; x < myImage.Width; x++)
{
   my_colour_list.Add(output_data.GetPixel(x, myImage.Height))
}

//Left
for (int y = 0; y < myImage.Height; y++)
{
   my_colour_list.Add(output_data.GetPixel(0, y))
}

//Right
for (int y = 0; y < myImage.Height; y++)
{
   my_colour_list.Add(output_data.GetPixel(myImage.Width, y))
}

//Write the info to a text file (You will have Red, Green, Blue for colour image)
//It's up to you how you make the format

System.IO.StreamWriter file_to_write = new System.IO.StreamWriter("c:\\test.txt");

foreach(Color var in my_colour_list)
{
    //To save R/G/B and Alpha
    file_to_write.WriteLine(var.toString());
    //or just R G B
    file_to_write.WriteLine(var.R.toString());
    file_to_write.WriteLine(var.R.toString());
    file_to_write.WriteLine(var.R.toString());
}</colour></color>



希望这会有所帮助,
干杯,

克里斯



Hope this helps,
Cheers,

Chris


任何图像的边缘像素应为
The edge pixels of any image should be
(0, 0)
(image.width - 1, 0)
(0, image.height - 1)
(image.width - 1, image.height - 1)



我的错,这是拐角而不是边缘.



My fault, this gives corners, not edges.


您可以使用CImage对象

#include< atlimage.h>

CImage TempObj;
TemObj.Load(图像文件名");

//您可以从
获取Dimesion TempObj.GetHeight();
TempObj.GetWidth();

//要获取GetPixel数据
TempObj.GetPixel(X,Y);
you can use CImage object

#include <atlimage.h>

CImage TempObj;
TemObj.Load("Image File name");

//you can get Dimesion from
TempObj.GetHeight();
TempObj.GetWidth();

//To GetPixel Data
TempObj.GetPixel(X,Y);


这篇关于从图像获取边缘像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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