Orchface Posted July 24, 2020 Share Posted July 24, 2020 Hello, I am working on a geographical map image that will ultimately be interpreted by a computer program. Thus, it is crucial that the final resized image has exactly the same colors as the original. I cannot have any blended/antialiased pixels anywhere on the resized image. I read up on a similar thread from many years ago, and it pointed to TR's color reducer plugin: https://forums.getpaint.net/topic/29424-trs-color-reducer-and-palette-maker-2014-08-01/ However, I couldn't figure out how to use this plugin to accomplish what I need. The only resizing algorithm that seems to avoid blending pixels is the Nearest Neighbor, but if I resize the image 200% for example, each 1 pixel on the original image turns into a 2x2 homogenous square on the resized image. Although it retains the exact colors of the original, I need the quality to be comparable to the Best Quality or Bicubic algorithms. Here is a sample of part of my map image. Original: Resized using Bicubic: The issue here is that the algorithm blends pixels at the borders of different colors, so this image has a much larger palette than my original. I can't have this, since the computer can only process the colors in the original. Resized with Nearest Neighbor: This preserved the color palette of the original, but it turned each pixel from the original into a 2x2 square of homogenous pixels. This greatly reduces the sharpness and quality of the resized image. In summary, I need to be able to resize the image with the quality of the Bicubic algorithm, but avoid blending pixels like the nearest neighbor algorithm. I can't do anything manually, since my map is over 40000x20000 pixels, and it would take years to go over every blended edge with a tool. If someone knows how to do this using a plugin without any kind of manual input, that would be great. Thank you for your help! Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted July 24, 2020 Share Posted July 24, 2020 8 minutes ago, Orchface said: TR's color reducer plugin: https://forums.getpaint.net/topic/29424-trs-color-reducer-and-palette-maker-2014-08-01/ However, I couldn't figure out how to use this plugin to accomplish what I need. There's an alternative that I like much better called Selective Palette. 10 minutes ago, Orchface said: If someone knows how to do this using a plugin without any kind of manual input, that would be great. It's not clear what you mean by manual input, but you could try Hawkynt's 2D-ImageFilter Library. 1 Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
BoltBait Posted July 24, 2020 Share Posted July 24, 2020 13 minutes ago, Orchface said: I need to be able to resize the image with the quality of the Bicubic algorithm, but avoid blending pixels like the nearest neighbor algorithm. You want your cake and eat it too... The "quality" of bicubic is BECAUSE of the pixel blending. Without pixel blending you get Nearest Neighbor. You can't have it both ways. That said, you might be able to do something with Floyd-Steinberg Dithering... resize with Bicubic then Dither your image. If you need a custom palette added to the plugin, I might be able to help with that. 1 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
Orchface Posted July 24, 2020 Author Share Posted July 24, 2020 (edited) 22 minutes ago, BoltBait said: You want your cake and eat it too... The "quality" of bicubic is BECAUSE of the pixel blending. Without pixel blending you get Nearest Neighbor. You can't have it both ways. 23 minutes ago, toe_head2001 said: It's not clear what you mean by manual input, but you could try Hawkynt's 2D-ImageFilter Library. Here is a photo that I manually edited after resizing to produce the intended effect (there was no way to do this in a single step during resize): Original (two colors only): Resized 200% with bicubic, and then manually recolored to remove blended pixels (still two colors only): Notice that in the second image, the smooth rasterization is present, yet all pixels are 100% black or white. No gray/blended pixels to be found. And the diagonal edges from the first image were transformed into single-pixel lines in the resized image, rather than just turning each pixel into a 2x2 square like Nearest Neighbor. Here is an illustration of a 200% resize using smooth rasterization without any blended pixels: This is what I mean by preserving quality but doing away with blended colors. Sorry if I was unclear. Edited July 24, 2020 by Orchface Quote Link to comment Share on other sites More sharing options...
BoltBait Posted July 24, 2020 Share Posted July 24, 2020 If we're talking about 2 color images (black and white), you can do your resize with bicubic and then use Brightness/Contrast to bring back the 2 colors. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
toe_head2001 Posted July 24, 2020 Share Posted July 24, 2020 His map has multiple colors. The Selective Palette plugin is probably the best bet. 1 Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
BoltBait Posted July 24, 2020 Share Posted July 24, 2020 51 minutes ago, Orchface said: Sorry if I was unclear. In your example, you changed two pixels from white to black. In my example, I changed two pixels from black to white. If the background is transparent instead of white, this MIGHT be possible. But, then what happens if the two original pixels are different color... what color would you make the new pixels? You see, this thing you're asking for is VERY complicated. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
Orchface Posted July 24, 2020 Author Share Posted July 24, 2020 (edited) 29 minutes ago, BoltBait said: In your example, you changed two pixels from white to black. In my example, I changed two pixels from black to white. If the background is transparent instead of white, this MIGHT be possible. But, then what happens if the two original pixels are different color... what color would you make the new pixels? You see, this thing you're asking for is VERY complicated. Good point. By this point, I think it is safe to say that there is no pre-existing algorithm which can accomplish this. The colors would be determined by a simple difference comparator. I'm not altering the brightness or adding any filters to this image, so Euclidian color distance should work fine for finding a numerical representation of similarity between two colors. The algorithm would go as follows: 1. get a set of all colors on the original image palette 2. resize the image using bicubic 3. get a set of all pixels whose colors do not match one of those on the original palette 4. for each pixel, go through the set of colors from the original palette, find the color with the least difference from this pixel's color, and set this pixel's color to that color. Obviously the TC on this algorithm is horrible, but you get the idea. Here's a portion of the half-circle from earlier with two arbitrary colors, resized with bicubic. Now here is what is might look like afterward: The blended pixels whose color was closer to #FFD800 were turned to #FFD800 and the pixels whose color was closer to #0094FF were changed to #0094FF. This could be done for three or more colors as well. Edited July 24, 2020 by Orchface Quote Link to comment Share on other sites More sharing options...
Orchface Posted July 24, 2020 Author Share Posted July 24, 2020 2 minutes ago, welshblue said: Just a thought. On the map question - surely the problem starts from a poorly cut out British Isles and is then compounded when resizing ? More care = better result ? The reason it looks weird is because I am using a Robinson projection. Trust me, the original image is exactly how it should be. I am making a topographic relief map that will be processed by a program; that's why I need the colors and scaling to be precise. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.