提取raw图像边缘的程序,请大家帮忙看一下,帮帮我这只可怜的菜鸟(分不够可以再加哦)

lhxm007 2003-03-05 11:54:23
本人是只超级菜鸟,只有一点C语言的经验,刚接触VC++,感觉是雾里看花呀……
现在我需要提取一幅图像的边缘显示在新图像中,我从一本书上查到一个程序:
//程序名:cut_apart_1
//程序功能:运用Laplacian算子分割图像
//Button1.caption="打开图像"
//Button2.caption="转化成灰度图像"
//Button3.caption="Laplacian算子法分割"
//Image1.name=Image1
//Image2.name=Image2
//TPogressBar1.name=ProgressBar1
//OpenDialog1.name=OpenDialog1
//头文件f411_2.h
#ifndef f411_2H
#define f411_2H
#include<Classes.hpp>
#include<Controls.hpp>
#include<StdCtrls.hpp>
#include<Forms.hpp>
#include<Dialogs.hpp>
#include<ExtCtrls.hpp>
#include<math.h>
#include<Menus.hpp>
#include<Buttons.hpp>
#define MaxLenth 350000

class TForm1:bublic TForm
{
_published://IDE-managed Components
TOpendialog*OpenPictureDialog1;
TImage*Image1;
TButton*Button1;
TProgressBar *ProgressBar1;
TButton*Button2;
TImage*Image2;
TBitBtn*BitBtn1;
Void_fastcall Button1Click(TObject*Sender);
Void_fastcall Button2Click(TObject*Sender);
Void_fastcall Button3Click(TObject*Sender);
Private://User declarations
Public: //User declarations
_fastcall TForm1(TComponent*Owner);
};

extern PACKAGE TForm1*Form1;

#endif
class PictureOperation
{
public:
int PictureWidth;
int PictureHeight;
int GreyDegree[MaxLenth];
int NewGreyDegreen[MaxLenth];
public:
void ColorPicture_To_GreyPicture(Timage*Image1);
void Device_With_Laplacian(Timage*OutputImage);
void PictureOperaton::ColorPicture_To_GreyPicture(TImage*Image1);
{
int x,y;
int color;
int R,G,B;
int Y;
PictureWidth=Image1->Width;
PictureHeight=Image1->Height;
ProgressBar1->Visible=true;
ProgressBar1->Max=PcitureHeight;
ProgressBar1->Min=0;
if(PictureWidth*PcitureHeight<MaxLenth)
{
for(y=0;y<PictureHeight;y++)
{
for(x=0;y<PictureWidth;x++)
{
color=Image1->Canvas->Pixels[x][y];
R=color&255;
G=(color/256)&255;
B=(color/256/256)&255;
Y=0.3*R+0.59*G+0.11*B;
GreyDegree[y*PictureWidth+x]=Y;
Image1->Canvas->Pixel[x][y]=RGB(Y,Y,Y)
}
ProgressBar1->Position++;
}
}
ProgressBar1->Visible=false;
}
void PictureOperation::Device_With_Laplacian(TImage*OutputImage)
{
int x,y;
int new_grey;
OutputImage->Width=PictureWidth;
OutputImage->Height=PictureHeight;
ProgressBar1->Visible=true;
ProgessBar1->Max=PictureHeight;
ProgressBar1->Min=0;
ProgressBar->Position=0;
for(y=1;y<PictureHeight-1;y++);
{
for(x=1;x<PictureWidth-1;x++)
{
new_grey=GreyDegree[(y-1)*PcitureWidth+(x)]+GreyDegree[(y+1)*PictureWidth+(x)]+GreyDegree[(y-1)*PcitureWidthO+(x-1)]+GreyDegree[(y)*PcitureWidth+(x+1)]-4*GreyDegree[(y)IPcitureWidth+(x)];
if(new_grey<0)new_Ogrey=-new_grey;
OutputImage1->Canvas->Pixel[x][y]=RGB(new_grey,new_grey,new_grey);
}
ProgressBar1->Position++;
}
ProgressBar1->Visible=false;
}



//f411_2.cpp
#include<vc1.h>
#pragma hdrstop
#include "c2.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm *Form1;
PictureOperation PictureProcessing;
_fastcall TForm1::TForm1(TComponent*Owner):TForm(Owner)
{
}
Void_fastcall TForm1::Button1Click(TObject*Sender)
{
if(OpenPictureDialog1->Execute()==true)
{
Image1->Pciture->LoadFromFile(OpenPictureDialog1->FileName);
}
}
Void_fastcall TForm1::Button3Click(TObject*Sender)
{
Image1->Visible=false;
PictureProcessing.ProgressBar1=ProgressBar1;
PictureProcessing.Device_With_Laplacian(Image2);
}
Void_fastcall TForm1::Button2Click(TObject*Sender)
{
PictureProcessing.ProgressBar1=ProgressBar1;
PictureProcessing.ColorPicture_To_GreyPicture(Image1);
}
我把它作为c1.cpp和c2.cpp文件放在工程的Source Files中,出现了一些问题:
编译时系统总说找不到include中的*.h和*.hpp文件,像Classes.hpp、vc1.h等。而且我也不知道这个程序能不能对RAW图像文件进行边缘提取
谁有对RAW图像文件进行边缘检测、滤除噪声和平滑所得边缘的源代码,请发到我的邮箱:lhxm007@sina.com中,感激不尽!!!(给点建议也有分哦)
...全文
121 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
winphoenix 2003-03-10
  • 打赏
  • 举报
回复
upup
wshcdr 2003-03-10
  • 打赏
  • 举报
回复
gz
lhxm007 2003-03-10
  • 打赏
  • 举报
回复
恕我愚笨,怎么用指针指向raw文件啊??
我只有一点点C语言经验(2年前学的,现在跟没学过差不多了)
有劳大家了
flysundy 2003-03-10
  • 打赏
  • 举报
回复
raw格式就是如你所说的那样,
“如何在VC中把各点的灰度值读出来,存在一个像array[x][y]这样的二维数组中??”
你直接用指向raw图象的指针不就行了,指针可以看成一维或二维数组
lhxm007 2003-03-10
  • 打赏
  • 举报
回复
呵呵,今天我淘了半天,终于掏到点raw文件的知识,大家听听对不对:
raw是一种非常简易的图像文件存储格式,它没有头文件(不知头文件是个什么东东?)
它存储的是一个矩阵,行数就是图像列上的像素数,列数就是图像行上的像素数
矩阵中x行y列的数值就是图像中第x行y列的像素的灰度值(对黑白图片而言)
现在我想问问大家:
如何在VC中把各点的灰度值读出来,存在一个像array[x][y]这样的二维数组中??
如果有哪位高人贴出代码,感激不尽! *^_^*
lhxm007 2003-03-09
  • 打赏
  • 举报
回复
唉,我现在快郁闷死了。
虽然有些书上有数字图像处理方面的内容,但对*.raw文件却很少有提及的。我现在只能在Photoshop里打开这个文件,自己编程处理的话压根无从下手。
我也很想自己设计算法,可是编程知识实在太少,即使知道了算法也编不出程序。从头学吧,又太慢,真是急人啊!
:[
jack_wq 2003-03-05
  • 打赏
  • 举报
回复
提取算法最好自己设计,关于边缘提取有很多方法,看你的图像是属于那一种类型!
flysundy 2003-03-05
  • 打赏
  • 举报
回复
改成#include "*.h"试试
你想找“RAW图像文件进行边缘检测、滤除噪声和平滑所得边缘的源代码”
我建议你找本专门的图象处理方面的书,比如:《vc与数字图象处理》 邮电出版社,等等,去书店翻翻。你要是只看源代码是很难看懂的

19,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧