How to create a property for an image?

  • Thread starter Thread starter MustafaUysal
  • Start date Start date
M

MustafaUysal

Guest
Hi, i am new with C#.

I created some filters for image processing operations. Then, i moved my filters to a class. And my filters are working. But i think i can't use property (which i created for my image) properly. And i need some support. How should use them?

This is from Form1.cs

private void sliderKernel_MouseUp(object sender, MouseEventArgs e)
{
Filtreler f1 = new Filtreler();

Bitmap Orj = new Bitmap(pBox_SOURCE.Image);

f1.Imge = Orj;

int SablonBoyutu =
int.Parse(sliderKernel.Value.ToString());


if (SablonBoyutu % 2 == 1)
{
f1.addnoise(f1.Imge);
pictureBoxNoisyImg.Image = f1.Imge;
Bitmap MeanImg = (Bitmap)f1.Imge.Clone();
f1.meanfilter(SablonBoyutu, MeanImg);
pBox_PROCESSED.Image = MeanImg;
}

else
{
//doing something
}
}


and this part is from my class file (i think this is the weird part)

#region imge property
private Bitmap resim;
public Bitmap Imge
{
get { return resim; }
set { resim = value; }
}
#endregion imge property



and this is my addnoise() method

#region Gürültü Ekleme
public void addnoise(Bitmap GirisResmi)
{
int ResimGenisligi = GirisResmi.Width;
int ResimYuksekligi = GirisResmi.Height;
Random rand = new Random();
int randpixelr, randpixelg, randpixelb;
for (int i = 0; i < ResimGenisligi; i++)
{
for (int j = 0; j < ResimYuksekligi; j++)
{
if ((i * i + j) % 100 == 0)
{
randpixelr = rand.Next(0, 255);
randpixelg = rand.Next(0, 255);
randpixelb = rand.Next(0, 255);

GirisResmi.SetPixel(i, j,Color.FromArgb(randpixelr, randpixelg, randpixelb));
}
}
}
return;
}
#endregion

Continue reading...
 
Back
Top