החלת מסנן הממוצע ומסנן וינר

החלת מסנן הממוצע ומסנן וינר

המסנן הממוצע הוא טכניקת סינון דיגיטלית לא לינארית, השימוש בה נפוץ להסרת רעש. הפחתת הרעש הזה היא שלב טיפול סטנדרטי לשפר את התוצאות של עיבודים מאוחרים. מסנן וינר הוא מסנן לינארי סטציונרי אופטימלי (בריבוע ממוצע בין השגיאות) לתמונות עם רעש תוספתי והמופויות בהם. באמצעות Aspose.PSD עבור מפתחי API של .NET ניתן להחיל מסנן ממוצע על התמונה ולהחיל מסנן רעש גאוס וינר על התמונות. מאמר זה מדגים כיצד ניתן להחיל את מסנן הממוצע ואת מסנן רעש גאוס וינר על תמונות.

החלת מסנן ממוצע

Aspose.PSD מספקת מחלקת MedianFilterOptions כדי להחיל מסנן על RasterImage. קטע הקוד שסופק למטה מדגים כיצד להחיל את מסנן הממוצע על תמונת ראסטר.

// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET
string sourceFile = dataDir + @"sample.psd";
string destName = dataDir + @"median_test_denoise_out.gif";
// Load the noisy image
using (Image image = Image.Load(sourceFile))
{
// Cast the image into RasterImage
RasterImage rasterImage = image as RasterImage;
if (rasterImage == null)
{
return;
}
// Create an instance of MedianFilterOptions class and set the size, Apply MedianFilterOptions filter to RasterImage object and Save the resultant image
MedianFilterOptions options = new MedianFilterOptions(4);
rasterImage.Filter(image.Bounds, options);
image.Save(destName, new GifOptions());
}

החלת מסנן רעש גאוס וינר

Aspose.PSD מספקת מחלקת GaussWienerFilterOptions כדי להחיל מסנן על RasterImage. קטע הקוד שסופק למטה מדגים כיצד להחיל את מסנן הרעש גאוס וינר על תמונת ראסטר.

// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET
string sourceFile = dataDir + @"sample.psd";
string destName = dataDir + @"gauss_wiener_out.gif";
// Load the noisy image
using (Image image = Image.Load(sourceFile))
{
RasterImage rasterImage = image as RasterImage;
if (rasterImage == null)
{
return;
}
// Create an instance of GaussWienerFilterOptions class and set the radius size and smooth value.
GaussWienerFilterOptions options = new GaussWienerFilterOptions(12, 3);
options.Grayscale = true;
// Apply MedianFilterOptions filter to RasterImage object and Save the resultant image
rasterImage.Filter(image.Bounds, options);
image.Save(destName, new GifOptions());
}

החלת מסנן רעש גאוס וינר לתמונה צבעונית

Aspose.PSD מספקת מחלקת GaussWienerFilterOptions גם לתמונות צבעוניות. קטע הקוד שסופק למטה מדגים כיצד להחיל את מסנן הרעש גאוס וינר על תמונה צבעונית.

// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET
string sourceFile = dataDir + @"sample.psd";
string destName = dataDir + @"gauss_wiener_color_out.gif";
// Load the noisy image
using (Image image = Image.Load(sourceFile))
{
// Cast the image into RasterImage
RasterImage rasterImage = image as RasterImage;
if (rasterImage == null)
{
return;
}
// Create an instance of GaussWienerFilterOptions class and set the radius size and smooth value.
GaussWienerFilterOptions options = new GaussWienerFilterOptions(5, 1.5);
options.Brightness = 1;
// Apply MedianFilterOptions filter to RasterImage object and Save the resultant image
rasterImage.Filter(image.Bounds, options);
image.Save(destName, new GifOptions());
}

החלת מסנן רעש תנועה וינר

Aspose.PSD מספקת מחלקת MotionWienerFilterOptions כדי להחיל מסנן על RasterImage. קטע הקוד שסופק למטה מדגים כיצד להחיל מסנן וינר תנועה על תמונת ראסטר.

// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET
string sourceFile = dataDir + @"sample.psd";
string destName = dataDir + @"motion_filter_out.gif";
// Load the noisy image
using (Image image = Image.Load(sourceFile))
{
// Cast the image into RasterImage
RasterImage rasterImage = image as RasterImage;
if (rasterImage == null)
{
return;
}
// Create an instance of MotionWienerFilterOptions class and set the length, smooth value and angle.
MotionWienerFilterOptions options = new MotionWienerFilterOptions(50, 9, 90);
options.Grayscale = true;
// Apply MedianFilterOptions filter to RasterImage object and Save the resultant image
rasterImage.Filter(image.Bounds, options);
image.Save(destName, new GifOptions());
}

החלת מסנן תיקון על תמונה

מאמר זה מדגים את השימוש ב-Aspose.PSD עבור .NET לביצוע מסנני תיקון על תמונה. APIs של Aspose.PSD חשפו שיטות יעילות וקלות לשימוש כדי להשיג מטרה זו. Aspose.PSD עבור .NET חשף את מחלקת BilateralSmoothingFilterOptions ואת מחלקת SharpenFilterOptions לפילטרציה. מחלקת BilateralSmoothingFilterOptions דורשת מספר שלם כגודל. השלבים לביצוע כתה הם פשוטים כפי שמוצג להלן:

  1. טען תמונה באמצעות שיטת היצירה Load שנחשפה על ידי מחלקת התמונה
  2. המר את התמונה ל-RasterImage
  3. צור מופע של BilateralSmoothingFilterOptions ו- SharpenFilterOptions
  4. קרא לשיטת RasterImage.Filter תוך ציון מלבן כגבולות תמונה ומופע מחלקת BilateralSmoothingFilterOptions
  5. קרא לשיטת RasterImage.Filter תוך ציון מלבן כגבולות תמונה ומופע מחלקת SharpenFilterOptions
  6. כוונן את הניגודות
  7. הגדר בהירות
  8. שמור את התוצאות.

שימוש באלגוריתם אחזור ברדלי

אלגוריתם העיקול של התמונה משמש ביישומי גרפיקה. המטרה של העיקול של תמונה היא לסווג פיקסלים כ"כהים" או “בהירים”. API של Aspose.PSD מאפשר לך להשתמש בעיקול הגרסה התחתונה בעת המרה של תמונות. קטע הקוד הבא מראה לך כיצד להגדיר את ערך העיקול ולהפעיל את אלגוריתם העיקול של ברדלי.

// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET
string sourceFile = dataDir + @"sample.psd";
string destName = dataDir + @"binarized_out.png";
// Load the noisy image
// Load an image
using (PsdImage image = (PsdImage)Image.Load(sourceFile))
{
// Define threshold value, Call BinarizeBradley method and pass the threshold value as parameter and Save the output image
double threshold = 0.15;
image.BinarizeBradley(threshold);
image.Save(destName, new PngOptions());
}