2
\$\begingroup\$

This is a wolfram language program I wrote for super-resolution, in this case meaning to guess at how to increase the the resolution, and so detail shown in a raster image such as a photograph.

It uses a similar but different aproach to its successor, which is much better program, so please start with the new aproach here instead: Super Resolution in the Wolfram Language, Attempt 2



For those still on this page, both approaches are based on self similarity, exploiting large parts of images that are similar to small parts, to attempt to increase the resolution of the image.

output

Thease images are the original image image1, the image enlarged with simple interpolation, and the full result, using the super-resolution process.

The planks above the dog seem to be as good as it gets, the mess to the right apparently having a lower threshold.

There appeared to be a large performance hit to combining lines, using line breaks to visually show structure, the code is therefore more broken up with assignments a = ... than I'd like.

There are various possible improvements, such as having image2 broken into overlapping chunks, giving more data to match from. Or having the chunks that form the result being transparent and overlapping.

ur1 = "http://placepuppy.it/150/200";

image1url = ur1;
image1Scale = 2;
image2url = ur1;
grid = 16;
threshold = 1.5;
RQ = 1;

e = Import[image1url, "Image"];
image1 = ImageResize[e, Scaled@image1Scale];
image2 = Import[image2url, "Image"];
a = ImagePartition[image1,grid];
image1andResultImageWidth = Length@a[[1]];
image1chunks = Flatten@a;
image2chunks = Flatten@ImagePartition[image2, grid];
b = (Thread@{#, image2chunks})&;
image1Image2ChunkPairsInImage1Groups = b/@image1chunks;
chunkPairDist = ImageDistance[#[[1]], #[[2]]]&;
c = MinimalBy[#,chunkPairDist,RQ][[RQ]]&;
bestMatchForEachImage1ChunkAsPair = c/@image1Image2ChunkPairsInImage1Groups;
d = If[chunkPairDist@#<threshold, #[[2]], #[[1]]]&;
flatResultImageAsChunks = d/@bestMatchForEachImage1ChunkAsPair;
{e, image1, ImageAssemble@Partition[flatResultImageAsChunks, image1andResultImageWidth]}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.