Hi, i am new with C# and OOP.
I created a method (it blurs an image) . And it works well. I will create another method. And i need blurred image as input parameter. But i don't know how to do this? (I tried something. But none of them didn't work)
Here is my try:
- private void sliderKernel_MouseUp(object sender, MouseEventArgs e)
- {
- Filtreler f1 = new Filtreler(); //Filtreler is name of my class
- f1.Img = new Bitmap(pBox_SOURCE.Image);
- int kernelsize = sliderKernel.Value;
- Bitmap MeanImg = f1.meanfilter(kernelsize, f1.Img); //this method works well.now, i would like to use MeanImg
- pBox_PROCESSED.Image = MeanImg;
- f1.CorrectShade(f1.Img, MeanImg); //But i can't. All the pixel values are come as zero
- pBoxShadeCorrection.Image = MeanImg;
- }
- public Bitmap Img { get; set; } //my Properties
- public Color PixelValue { get; set; }
- public Bitmap meanfilter(int kernelsize, Bitmap InputImage)
- {
- Bitmap CikisResmi = new Bitmap(GirisResmi.Width, GirisResmi.Height);
- //blurring operations
- return CikisResmi;
- //I blurred the image. No problem with this method
- }
- public Bitmap CorrectShade(Bitmap InputImage,Bitmap BlurredImage)
- {
- Color PixelVauleBlurred;
- int divR,x,y;
- int ImgWidth = InputImage.Width;
- int ImgHeight = InputImage.Height;
- for (x = 0; x < ImgWidth; x++)
- {
- for (y = 0; y < ImgHeight; y++)
- {
- PixelVauleBlurred = BlurredImage.GetPixel(x, y);
- PixelValue = InputImage.GetPixel(x, y);
- divR = Convert.ToInt16(1f*OkunanRenk.R / PixelVauleBlurred.R); //Error line //Error message:System.DivideByZeroException: 'Attempted to divide by zero.'
- BlurredImage.SetPixel(x, y, Color.FromArgb(divR, divR, divR));
- }
- }
- return BlurredImage;
- }
Tyler MilesPosted Aug 4, 2019, 10:04 AM
Mario ScheerenPosted Aug 4, 2019, 4:09 AM
Afzaal Ahmad ZeeshanPosted Aug 3, 2019, 4:29 PM
Tyler MilesPosted Aug 3, 2019, 3:45 PM
Afzaal Ahmad ZeeshanPosted Aug 3, 2019, 2:40 PM
Error message:System.DivideByZeroException: 'Attempted to divide by zero.'
How you can solve this? You cannot. However, you can still try to prevent the error from showing up, and to do that just do this,
Tyler MilesPosted Aug 3, 2019, 2:31 PM
Mario ScheerenPosted Aug 3, 2019, 1:43 PM