DOS Games Message Board
DOS Games Discussion
A message board to talk about DOS games, get help, and find old games.
Do NOT post warez or abandonware requests please
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
NEW! has been massively upgraded to v2.0 with TONS of new features!
Check out the new design and dozens of new features including online play!

A method of removing JPEG artefacts from old screenshots

Post new topic   Reply to topic    DOS Games Discussion Forum Index -> General Off-Topic
Author Message
Demoniac Demo maniac
Demoniac Demo maniac

Joined: 05 Dec 2010
Posts: 2500

PostPosted: Wed Oct 04, 2017 10:45 am     Post subject: A method of removing JPEG artefacts from old screenshots Reply with quote

JPEG compression has ruined many an old screenshot in the 90s, but there's a way to somewhat reduce the damage.

For example, here's a screenshot from Tyrian that comes from the Epic MegaGames website (magnified at 2x using nearest neighbour interpolation for better viewing):

There's quite noticeable tiling, overall blurriness and distortions around the edges known as mosquito noise. I've been trying to figure out a way to reduce these kinds of artefacts, and came up with the following method using GIMP. The result is shown below:

The much cleaner image is accomplished by the following steps:

1. Import the source image into GIMP. Personally I prefer to first convert it from JPEG to a lossless format prior to importing but I think it doesn't actually make any difference.

2. Scale the image to 400% of its original size (which is 1280x800 in the case of a 320x200 image) setting interpolation to None (other software may call this the nearest neighbour interpolation).

3. Apply Median filter at the redius of 2. To do this, go Filters -> Enhance - > Despeckle, in the dialog box uncheck Adaptive and Recursive (if checked), set Radius to 2, Black level to -1 and White level to 256. In Photoshop, just use the Median filter with the same radius. This will reduce some of the mosquito noise.

4. Apply selective Gaussian blur (Filters -> Blur -> Selective Gaussian Blur). The Radius and Threshold levels might need to be adjusted for each image individually to achieve adequate mosquito noise removal. For the image above, I used Radius 10 and Threshold 20.

5. Apply the Pixelise filter (Filters -> Blur -> Pixelise) with pixel width and height both set to 4. This will effectively revert the image to its state when it was scaled up from the original size at 400% with the nearest neighbour interpolation.

6. Apply the sharpen filter at a high level of sharpness. I used 50 in this example. This is optional but will help make the resulting image more crisp by offsetting the effects of the blur filter used above.

7. Scale the image down to its original size. The Sinc3 (Lanczos) interpolation method seems to produce good results here.

Note that wile this method reduces visible mosquito noise, it does not address other distortions resulting from JPEG compression, such as discolouration, colour distortion, blurring and loss of image detail due to the former. Also areas with low contrast between neighbouring pixels get more blurry due to the selective Gaussian blur filter, which may result in some loss of detail. However overall the image is cleaned from the noticeable JPEG compression artefacts while preserving much of original detail.
Back to top
Demoniac Demo maniac
Demoniac Demo maniac

Joined: 05 Dec 2010
Posts: 2500

PostPosted: Sun Dec 24, 2017 10:10 am     Post subject: Reply with quote

I've also come up with a way to kinda-sorta improve image quality for screenshots mangled by GIF compression. Here's an example, one of the official screenshots for Crazy Drake (again, magnified by 2x with the nearest neighbour method):

The GIF compression artefacts result in checkerboard-esque patterns of contrasted pixels due to dithering. I've tried to remove them or at least make them less pronounced, to the following result:

It's not perfect but at least somewhat better. This was accomplished with the following steps:

1. Upscale the image 4x (1280x800 in this case) using nearest neighbour.

2. Run the Median filter at 2 pixel radius (see the first post above for how to do this in GIMP).

3. Run Selective Gaussian Blur at 5 pixel radius and a threshold of 100.

4. Scale the image down to original size using Bicubic interpolation.

Selective Gaussian blur with higher radius and/or threshold may or may not yield even better results.

UPD: Here's an alternate, simpler method that seems to be even better:

1. Convert the image to PNG (24-bit colour), and use Selective Gaussian Blur without resizing it at the radius of 2 and threshold of 100.

2. Export the image as GIF.
Back to top
Demoniac Demo maniac
Demoniac Demo maniac

Joined: 05 Dec 2010
Posts: 2500

PostPosted: Wed May 30, 2018 5:37 am     Post subject: Reply with quote

Suddenly I realised that the waifu2x scaler algorithm can also do noise reduction, and gave it a try via this implementation. I think it does a pretty good job. Here's an official Duke3D screenie for example:

And here's the result of waifu2x' noise reduction, using level 3 (because the original is that noisy)

I think there's quite a noticeable improvement, and without much loss of actual image detail.

And here's what it does to an original Shadow Warrior shot (noise level 2):

The result is clearly superior to what I got with my method described above:

waifu2x got rid of the ringing and mosquito noise, and the text on the HUD is clearly readable. There's some minor detail loss but the gains of removing the noise outweigh that.

For another test, let's take a terribly noisy screenshot that was damaged by successive JPEG conversions:

Now remove noise at level 3:

Now that's pretty decent, don't you think? Not perfect, but quite better.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> General Off-Topic All times are GMT - 5 Hours
Page 1 of 1


Powered by phpBB © 2001, 2005 phpBB Group and Ask an Expert
Also powered by Darren and the other admin and mods' hard work! ;)