Speckling artifacts happen because compressing images to MrSID at high compression ratios requires approximating colors. In other words, “black” becomes “almost black.” While the human eye doesn’t ordinarily notice the difference, this can make it difficult, not to mention ugly, to mosaic images together. Speckling also happens with other background colors depending on the nodata value.
Cause:
Pixel values can change slightly anytime images are compressed. This means that a value of (1, 16, 21) in the original file can become (0, 16, 22) or something similar in the MrSID output. The shift is due to the way compression works. The higher the compresion ratio, the more significantly the pixel values can shift. This is typically not a problem as the user can see no difference between the two slightly different pixel values.
However, most viewers treat the nodata values as absolute. If you set nodata to black (0, 0, 0), and some of those black pixels get shifted even slightly to (0, 1, 0), they are no longer considered to be true nodata values and will not display as nodata in the viewer. When the viewer is set to make nodata values transparent it leads to a messy speckled border around the image.
Speckling around the edge of a mosaic with a white background:
Solution:
If your image has been rotated, lossily compressed in the past, or has areas of nodata, select the Despeckle button on the main window. For this example the true nodata value is (0, 0, 0) in the image. Using the despeckling tool makes the logic for determining nodata values “fuzzy” so that a pixel that is not exactly that value will still get considered to be nodata in output. How fuzzy the values can be is set by the Threshold number in Despeckling options. This is a cumulative value of how far all of the bands can be from true nodata in total. For example, using the default threshold of 8, a value of (0, 5, 3) will be considered nodata but a value of (0, 5, 4 ) will not.
Sometimes this can take a little experimenting to see what value is best for the data and compression ratio. You might have pixels with values (10, 2, 7) on dark rooftops that will get treated as nodata if you set the threshold too high. It is always a good idea to run a test encode job (with watermarks) on a couple of test images to be sure before running the final job.
The result:
Troubleshooting:
If you get an error message stating MarkFinder exceeded the number of allowed points [52201] the job will not run. This message indicates that the number of points found is higher than allowed by the despeckling tool. This can happen when the threshold or point spacing is set too high for your imagery. To fix this problem, increase either of these values in the despeckling tool. What should you change? It depends on your dataset!
The threshold determines how far away from "true nodata" a pixel value can be while still being considered transparent - the "fuzziness" described above. This is a sum of the differences from all three bands. So let's say that true nodata is 255,255,255 and the pixels around the border of the image are just slightly different than that. If you have a point threshold of 8, that means that any combination of (255,255,247 = sum of 3 away) or (250,254,253 = sum of 8 away from 255) etc will all be accounted for in the despeckler, and properly coded as transparent. But if there are points any further away from that such as (250,251,255 = sum of 9 away from 255) then that will NOT be transparent in output, because the sum of its differences are greater than 8. To get a good threshold setting, examine your speckled data to see what the largest value from "true nodata" is, and use that value for the threshold.
Point spacing is more important for rectangular or square imagery. The point spacing determines how far apart the "steps" are for the despeckling algorithm as it "walks" around the imagery. Anything on the imagery side of the step is not counted in the despeckler (meaning those points will still be speckled even if they fall into the classification above) and anything on the outside of the steps is removed entirely. This is usually a problem for non-rectangular images, especially round shapes, because this can cause curved lines to become jagged. For those images a lower point spacing is needed.
If changing these settings still does not produce a good result, try changing your output format to MrSID Generation 4 instead. This will create an alpha mask to handle transparency (rather than a pixel value) and solve most speckling problems. See our Nodata and Transparency knowledge base article for an in-depth description of the differences in transparency handling between different MrSID file formats.