The Nearest Post Box



I've recently been updating our series on dithering toinclude ordered dithering. However, in order to fullydemonstrate this I also updated the sample to include basiccolor quantizing with a fixed palette.

While color reduction and dithering are related, I didn't wantto cover both topics in a single blog post, so here we are witha first post on finding the nearest color via Euclideandistance, and I'll follow up in another post on ordereddithering.

Nearest

Find Your Nearest Postbox. The buyer would give delivery address, which is normally his or her nearest post office. At the receiving end, a notice slip is sent to the post box. Sending letters and parcels is part of the expat life in the Netherlands. Find the nearest post office and box and learn about mailing cost, sizes and more. Get directions to the mailbox nearest you.Results appear instantly based on your current location, or you may enter an address. We have the locations of over 200,000 mailboxes and post offices throughout the United States and its territories. Get directions to the mailbox nearest you.Results appear instantly based on your current location, or you may enter an address. We have the locations of over 200,000 mailboxes and post offices throughout the United States and its territories.

Getting the distance between two colors is a matter ofmultiplying the difference of each channel between the twocolors and then adding it all together, or if you want aformula, Wikipedia obliges handily

In C# terms, that translates to a helper function similar to thebelow

Note that the distance is the same between two colours no matterwhich way around you call GetDistance with them.

Finding the nearest color

With the ability to identify the distance between two colours,it is now a trivial matter to scan a fixed array of colorslooking for the closest match. The closest match is merely thecolor with the lowest distance. A distance of zero means thecolors are a direct match.

My Nearest Parcel Post Box

While the initial code is simple, using it practically isn't. Inthe demonstration program attached to this post, theFindNearestColor is only called once and so you probably won'tnotice any performance impact. However, if you are performingmany searches (for example to reduce the colors in an image),then you may find the code quite slow. In this case, youprobably want to look at caching the value of FindNearestColoralong with the source color, so that future calls just look inthe cache rather than performing a full scan (a normalDictionary<Color, int> worked fine in my limited testing). Ofcourse the more colours in the map, the slower it will be aswell.

While I haven't tried this yet, using an ordered palette mayallow the use of linear searching. When combined with a cachedlookup, that ought to be enough for most scenarios.

What about the Alpha channel?

For my purposes I don't need to consider the alpha value of acolor. However, if you do want to use it, then adjustGetDistance to include the channel, and it will work justfine.

TheMail drop box near me

Mailbox Collection Times Near Me

The images below were obtained by setting the value of the boxon the left to 0, 0, 220, 0, and the right 255, 0, 220, 0 -same RGB, just different alpha.

Postal Service Near Me

  • 2017-01-06 - First published
  • 2020-11-21 - Updated formatting
FilenameDescriptionVersionRelease Date
ColorDistanceDemonstration.zip
  • sha256: a791f5e43926bedbf9ba25606cf7d325046c708ca7f86e2f918d31c34b9ef613

Sample project for the finding nearest colors using Euclidean distance blog post.

06/01/2017Download

While we appreciate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?

Daniel Roe

My Nearest Post Box For Covid Test

You certainly know your stuff! Question: How could you find the 'next' color 'above' or 'below' two color that you've found the Delta-e of?