9
$\begingroup$

I am trying to make an "ostagram" like image using wavelet transforms and image keypoints.

See the following link: https://www.facebook.com/ostagram/

This is done using neural networks, which I at present am not sure how to implement in Mathematica.

What I am trying to do is the following:

  1. Import two images of the same size and type:

    testImage1 = Import["https://i.sstatic.net/TQnFX.jpg"];
    testImage2 = Import["https://i.sstatic.net/JAVdX.jpg"];
    
  2. Segment one image using ImageKeypoints with a specific size (in this case 25x25 px) of partitions:

    ImageSegment[img_, param_] :=
      Module[{i = img, p = param}, 
        ImageTrim[i, {#}, p] & /@ ImageKeypoints[i, "KeypointStrength" -> .001]
       ];
    n = ImageSegment[testImage1, 25];
    
  3. Use the wavelet transform on one image so that I can extract the detail coefficients and reassemble them into one image:

(takes the wavelet transform of the second image)

dwd = StationaryWaveletTransform[testImage2, CDFWavelet[], 3];

(only keeps detail coefficients)

detail = InverseWaveletTransform[dwd, Automatic, {___, 1 | 2 | 3}];
Binarize@detail

Now, how do I get the segmented images from the first image overlaid on the detailed wavelet coefficients to produce those cool images from the link?

Thanks for your help

$\endgroup$
2
  • $\begingroup$ It would help to include example images $\endgroup$ Commented Mar 9, 2016 at 20:58
  • $\begingroup$ Do you have any reason to expect that this wavelet operation can give anything remotely like the deep neural network images? $\endgroup$ Commented Mar 9, 2016 at 21:00

1 Answer 1

6
$\begingroup$

A example in the StationaryWaveletTransform(Application/ImageFusion) seem can do this

{image, txture} = 
 Import /@ {"https://i.sstatic.net/TQnFX.jpg","https://i.sstatic.net/JAVdX.jpg"}
img = Sharpen[image];
txt = ImageMultiply[txture, .5];
{dwdImg, dwdTxt} = 
  StationaryWaveletTransform[#, CDFWavelet[], 3] & /@ {img, txt};
{rval1, rval2} = #[{___, 1 | 2 | 3}, "Values"] & /@ {dwdImg, dwdTxt};
wind = Cases[dwdImg["WaveletIndex"], {___, 1 | 2 | 3}];
nimg = (Image[#1, Interleaving -> False] &) /@ (1/2 (rval1 + 2 rval2));
rnew = MapThread[Rule, {wind, nimg}];
rr = Append[rnew, 
   First[dwdImg[{0, 0, 0}, {"Image", "ImageFunction" -> Identity}]]];
dwdnew = DiscreteWaveletData[rr, CDFWavelet[], 
   StationaryWaveletTransform];
InverseWaveletTransform[dwdnew]

$\endgroup$
1
  • $\begingroup$ This looks cool +1. $\endgroup$ Commented Mar 22, 2017 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.