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.stack.imgur.com/TQnFX.jpg"];
    testImage2 = Import["https://i.stack.imgur.com/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$
  • $\begingroup$ It would help to include example images $\endgroup$ – Simon Woods Mar 9 '16 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$ – Simon Woods Mar 9 '16 at 21:00
6
$\begingroup$

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

{image, txture} = 
 Import /@ {"https://i.stack.imgur.com/TQnFX.jpg","https://i.stack.imgur.com/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$
  • $\begingroup$ This looks cool +1. $\endgroup$ – Anjan Kumar Mar 22 '17 at 8:40

Your Answer

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

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