Recent

Author Topic: Edge softening mystery  (Read 2510 times)

user5

  • Sr. Member
  • ****
  • Posts: 326
Edge softening mystery
« on: January 27, 2022, 12:35:36 am »
    I recently discovered something that you all may already know but I don't fully understand it yet.
    If I reduce the size of the attached 840x720 raster scan image (gears1.gif) to 420x360 (gears2.gif)
then the resulting half size image gears2.gif will automatically have non-raster scan internal edging!
    The external edging isn't that great but that can be fixed separately. The internal edging has mostly
acceptable quality. I haven't tested any other images yet but I'd like to know what's going on here since
this issue is directly related to my current Lazarus work.
    Is the edging automatically done by Windows Clear Type or is something else at work here like Alpha?
    This is really cool. I'm surprised that I'm only now finding this out.

user5

  • Sr. Member
  • ****
  • Posts: 326
Re: Edge softening mystery
« Reply #1 on: January 28, 2022, 10:47:28 am »
    I noticed that there were no comments on this topic and I think that is just as well since this edging method is limited
to only a few very simple, symmetrical, large foreground images in transparent pictures and videos.
    Even at its very best it still requires that the resulting images undergo further de-edging and re-edging though in a few
cases it can produce acceptable results and it is very fast. However, I will make sure that users are made aware of it.
    Thanks anyway and all praise to Lazarus.

AlexTP

  • Hero Member
  • *****
  • Posts: 1766
    • UVviewsoft
Re: Edge softening mystery
« Reply #2 on: January 28, 2022, 01:16:54 pm »
No replies? Because noone knows about these terms?

> The external edging isn't that great

> The internal edging

Unclear terms used.

lainz

  • Hero Member
  • *****
  • Posts: 3933
Re: Edge softening mystery
« Reply #3 on: January 28, 2022, 02:09:02 pm »
When you scale down a big image, its usually softened depending of the scaling mode you use.

circular

  • Hero Member
  • *****
  • Posts: 3796
    • Personal webpage
Re: Edge softening mystery
« Reply #4 on: January 29, 2022, 12:21:01 pm »
Yeah as Lainz said, down scaling an image will smooth it.

The reason is that each becomes becomes a weighted average of multiple pixels. So for example if you have 2x2 pixels in the original image that becomes one pixel, if have of the pixels are inside and half are outside of a shape, then you will have a color that is a mix of 50% of the inner color and 50% of the outer color.

This method is used by various rendering techniques to make antialiased edges.
Conscience is the debugger of the mind

ChrisR

  • Full Member
  • ***
  • Posts: 236
Re: Edge softening mystery
« Reply #5 on: January 31, 2022, 12:52:02 pm »
You may want to try out the Lazarus project Transform.lpi that allows you to evaluate different spatial filters.
  https://github.com/rordenlab/niimath/tree/development/src
In the attached screenshot I show the provided 256x256 pixel zone plate reduced 50% in the horizontal axis. You can choose different Filters from the drop down menu: Bilinear, Lanczos Sinc, and Mitchell.

When you reduce the sampling rate of a signal, you need to be aware of aliasing artifacts: frequencies higher than the Nyquist can appear as lower frequencies. The zone plate is designed to exhibit this. Different filters have different behavior: the Mitchell and Linear filters do not preserve high frequencies, which makes them more resistant to artifacts, while the sink preserves higher frequencies but can show ringing artifacts.

If you want to avoid downsampling artifacts, you want to consider an anti-aliasing filter. My own Lazarus projects use the method of Schumacher that adjusts kernel size to compensate for downsampling, though an alternative approach is to blur the input image at the Nyquist.
 https://github.com/erich666/GraphicsGems/tree/dad26f941e12c8bf1f96ea21c1c04cd2206ae7c9/gemsiii

In theory, you could apply a unsharp masking method to enhance these artifacts if you find them useful, though you may find a specialized edge detector better suited. Simple edge detectors include Sobel, Roberts cross, and Prewitt. More fancy edge detectors include the Canny method.
 


Also relevant:
https://nbviewer.org/urls/dl.dropbox.com/s/s0nw827nc4kcnaa/Aliasing.ipynb
https://neurostars.org/t/downsample-image/16677/7


 

TinyPortal © 2005-2018