MATLAB: Sharpen Image After Interpolation

image processingImage Processing Toolboxinterpolationkuwahara

Hi, I have a matrix/image with interpolation applied. The image consist of "box" regions of same values. At the edge of two box regions, the values are interpolated. Is there a way to remove the interpolation and assign the edges the value of the nearest neighboring box? So in the end the image will look sharp without interpolated values.
e.g. In the example image, the top and bottom data dots belong to different "boxes". At the edge that separate the "boxes", values are interpolated, the middle dot has a value somewhere in beween the top and bottom data dots. I want to replace the middle dot with its nearest neigboring value that was not interpolated.Example.PNG
Original Image
Example2.PNG
What I want the image to look like (roughly treated with Photoshop)

Best Answer

If you want to get rid of antialiased values and get sharper edges with no in between values, you can try a median filter with medfilt2(), or imquantize().
Or you can try a fancier thing like a Kuwahara filter.
Or you could try a mean shift filter.
If you want blurred lines, which has MORE colors instead of fewer, you can use imfilter() or conv2() or imgaussfilt() to blur the image.