两幅图进行相减(50分)

  • 主题发起人 主题发起人 chenliyan163
  • 开始时间 开始时间
C

chenliyan163

Unregistered / Unconfirmed
GUEST, unregistred user!
我想进行两幅图的相减得到的结果会怎么样,
 
怎么相减,
我想会是乱码
 
可以这样做。但我没有试过。理论上就可以。只要不破坏文件头。
 
这个实际也是可以的,因为一幅图像可以分为很多的点阵,而在计算机里面都是以0或1来表示的,当两个点阵相等时减出来的
图像就是等于一个白点,但假如说不相等时减出来的结果是一个有值的点,相当于一个黑点,这样我们可以明显地比较出前一
幅图跟后一幅图的不同之处了,关键是我不知道里面程序怎么写的,
 
为什么要相减,如果你非得做的话就先拿msdn研究一下位图的格式,如果是24位的话,
把他们转换成大小一样的图像,除去位图文件的头之外的像素你想怎么处理都行,例如叠加,
如果不是24位的画还涉及到调色板,先转换成24位图像

如果只是简单的按位运算而不考虑位图格式可能结果没有任何意义
 
我想让两幅图进行异或,怎么做,请高手帮忙
 
我有一幅圖,很有意思,在ie中正常顯示的是候是花,但是當你反選的時候,它就會是另一張圖片美女,就好象藏在花中一樣,請問高手們,這是如何實現的呢,如果要看樣圖,請發郵件給我:
rogue_xu@sina.com
 
我作过灰度图的相减,代码现在不在手边,留个妹儿,到时给你
如果有人作过其他的,也可以添一下的,我也想参考一下
 
用scanline就可以了。
结果应该是2图的不同的部分
---------------------------------
水晶控件
http://www.codeidea.com
 
您能告诉我那个程序是怎么写的吗?
 
那个控件下载不了啊,
 
TO:rogue_xu
我要看樣圖,請發郵件給我:11758@163.com
 
{功能:两灰阶图像逐点相减(减影),得到减影图像的处理函数
参数: Pic,Pic 两灰阶图像
picdev 得到的减影图像}
procedure DivPic(const Pic1,Pic2:TImage;var picdev:TImage;CutRect:TRect);
var
p1,p2,pdev:PByteArray;
x,y,x_s,y_s:integer;
byteValue:byte;
bmp1,bmp2,bmpdev:TBitmap;
MyRect:TRect;
begin
bmp1:=TBitmap.Create; //两灰阶图像与目标减影图像载入暂存图像
bmp2:=TBitmap.Create;
bmpdev:=TBitmap.Create;
bmp1.Assign(pic1.Picture.Bitmap);
bmp2.Assign(pic2.Picture.Bitmap );
bmpdev.Assign(pic1.Picture.Bitmap );
x_s:=0; //调整目标减影图像图像的大小,取小舍大
y_s:=0;
if bmp1.Width >x_s then x_s:=bmp1.Width;
if bmp2.Width <x_s then x_s:=bmp2.Width;
bmpdev.Width:=x_s;
// if bmpdev.Width <x_s then x_s:=bmpdev.Width;
if bmp1.Height >y_s then y_s:=bmp1.Height;
if bmp2.Height <y_s then y_s:=bmp2.Height;
bmpdev.Height:=y_s;
// if bmpdev.Height <y_s then y_s:=bmpdev.Height;
if (x_s<=0) or (y_s<=0) then exit; //灰阶图像不存在,则退出程序
for y:=0 to y_s-1 do //两图像逐点相减处理,存入目标图像
begin
p1:=bmp1.ScanLine[y];
p2:=bmp2.ScanLine[y];
pdev:=bmpdev.ScanLine[y];
for x:=0 to x_s-1 do
begin
if p2[x*3]>=p1[x*3] then
byteValue:=0 //p2[x*3]-p1[x*3]
else
byteValue:=p1[x*3]-p2[x*3];
pdev[x*3]:=byteValue;
pdev[x*3+1]:=byteValue;//p2[x*3+1]-p1[x*3+1];
pdev[x*3+2]:=byteValue;//p2[x*3+2]-p1[x*3+2];
end;
end;
picdev.Picture.Bitmap.Width:=CutRect.Right-CutRect.Left;
picdev.Picture.Bitmap.Height:=CutRect.Bottom-CutRect.Top;
MyRect:=rect(0,0,picdev.Picture.Bitmap.Width,
picdev.Picture.Bitmap.Height);
picdev.Picture.Bitmap.Canvas.CopyRect(MyRect,bmpdev.Canvas,CutRect);
// bmpdev.Canvas.CopyRect(fCutRect);
// picdev.Picture.Bitmap.Assign(bmpdev);
bmp1.Free;
bmp2.Free;
bmpdev.Free;
end;
 
多人接受答案了。
 
后退
顶部