0
我嘗試使用兩個圖像參數來控制項目中的圖像。問題是,當我在Emgu CV中應用任何公共無效函數後無法重新分配圖像時。 這是我的代碼:EMGU CV重新分配圖像
public static class Global
{
public static Image<Gray, byte> xrayPic;
public static Image<Gray, byte> rootPic;
}
private void takePhotoBtn_Click(object sender, EventArgs e)
{
Image<Bgr, Byte> ImageSrc = new Image<Bgr, Byte>(_subPath);
Image<Gray, Byte> GrayImage = ImageSrc.Convert<Gray, byte>();
Image<Gray, Byte> MedianImage = GrayImage.SmoothMedian(5);
Global.xrayPic = MedianImage;
Global.rootPic = MedianImage;
Global.xrayPic.Save(_subPath);
imgBox.Image.Dispose();
imgBox.Image = Global.xrayPic.Bitmap;
}
private void checkHistogram_CheckedChanged(object sender, EventArgs e)
{
if(checkHistogram.Checked)
{
Image<Gray, byte> tmpPic = Global.xrayPic;
tmpPic._EqualizeHist();
// Global.xrayPic._EqualizeHist();
imgBox.Image.Dispose();
imgBox.Image = tmpPic.Bitmap;
}
if(checkHistogram.Checked == false)
{
Global.xrayPic = Global.rootPic;
imgBox.Image.Dispose();
imgBox.Image = Global.xrayPic.Bitmap;
}
}
當我檢查到的複選框以應用功能__EqualizeHist(),它自動應用功能以調整第一PIC到第二PIC(如附加的圖像)。然而,當我取消,但不回我的root_Pic(第二張圖先PIC) This is the demonstration for my code
它的工作!非常感謝! –
我的疑問是爲什麼?將一個圖像變量的值分配給另一個圖像變量並將第一個圖像克隆到第二個圖像變量之間有什麼區別? –
@PabloGonzalez直接賦值並不實際賦值爲「Value」,而只是複製其地址。這就是爲什麼他需要深層複製。如果你仍然懷疑,那麼研究淺層和深層複製的概念。 –