1
$\begingroup$

I have a set of images which need to be filtered by different filters. So I have made an interface in which the user can choose his or her filter. However I now want to manipulate the degree of the filter. Meanfilter[imagedata, {1,2,3 etc.)]. I now have a working manipulate:

Manipulate[ArrayPlot[MedianFilter[imageDataOr, i]], {i, 0, 10, 1}]

but the image does not refresh when I use it in a graphical user interface. The code is:

outM = DialogInput[{
    TextCell["Adjust filter you want to use"],
    Row[{Manipulate[
       ArrayPlot[MedianFilter[imageDataOr, i]], {i, 0, 10, 1}]}],
    Button["Continue", DialogReturn[1]]}];

image=Import["https://i.sstatic.net/Ekhbd.jpg"];
imageDataOr=ImageData[image]

 []

EDIT: You have to grayscale the image.

To be specific. When I use the slider everything works fine, but when I click on a specific point it does not refresh

The solution is now:

butOut = DialogInput[{
   TextCell["Choose the filter you want to use"], 
   Button["Median Filter", DialogReturn[1]]}];
If[butOut == 1, outM = DialogInput[{
    TextCell["Adjust filter you want to use"],
    Row[{Manipulate[
       ArrayPlot[
        ImageData@MedianFilter[Image[imageDataOr], ManipulateI], 
        PreserveImageOptions -> False], {{ManipulateI, 1, "t1"}, 0, 
        10, 1}, SynchronousUpdating -> True, 
       LocalizeVariables -> False],
      Manipulate[
       ArrayPlot[
        ImageData@MedianFilter[Image[imageDataOr], ManipulateJ], 
        PreserveImageOptions -> False], {{ManipulateJ, 1, "t2"}, 0, 
        10, 1},
       SynchronousUpdating -> True, LocalizeVariables -> False]}],
    Button["Continue", DialogReturn[1]]}]; 
 originalCorrected = MedianFilter[imageDataOr, ManipulateI]; 
 movedCorrected = MedianFilter[imageDataMo, ManipulateJ];
 ];

Kind regards,

Glenn

$\endgroup$
0

1 Answer 1

2
$\begingroup$

See DialogInput > Possible Issues as a possible explanation of the freeze issue.

enter image description here enter image description here enter image description here

It is also a good idea to be aware of PreserveImageOptions which may also disconnect the control from the content.

So using the combination PreserveImageOptions->False for ArrayPlot and SynchronousUpdating -> True for Manipulate seems to fix the issue:

img = ExampleData[{"TestImage", "Tree"}];

outM = DialogInput[{TextCell["Adjust filter you want to use"], 
   Row[{Manipulate[ArrayPlot[ImageData@MedianFilter[img, i],
                   PreserveImageOptions->False], {i, 0, 10, 1},
       SynchronousUpdating -> True]}], 
   Button["Continue", DialogReturn[1]]}]

(* you could also use ArrayPlot[MedianFilter[ImageData@img, i]] but it is painfully slow. *)

enter image description here

enter image description here

$\endgroup$
5
  • $\begingroup$ I have tested your program but this image is also not adjusting on the manipulated value. I don't know if this is due to the running time or something.. $\endgroup$
    – Glenn
    Commented Oct 13, 2014 at 20:49
  • $\begingroup$ I see, and I have edited it now. But the problem I have now is when I don't use the slider. If I drag and drop everything works fine. But when I click on a specific point (without dragging) the image does not refresh. You know were this comes from? And when I start sliding again it does not work again and I have to restart the the evaluation $\endgroup$
    – Glenn
    Commented Oct 13, 2014 at 20:58
  • $\begingroup$ Thank you so much, it works now :)!! I have still a small question, how can I use the value of the manipulation in a new function? $\endgroup$
    – Glenn
    Commented Oct 13, 2014 at 21:40
  • $\begingroup$ @ kguler I have to add LocalizeVariables -> False in the manipulate and define the variables outside the Manipulate (make them global) I have updated the code $\endgroup$
    – Glenn
    Commented Oct 13, 2014 at 21:49
  • $\begingroup$ Glenn, we need to clean up the comments above (I will delete mine in a moment.) And please remember that if you find an answer useful, you can Upvote and/or Accept it. $\endgroup$
    – kglr
    Commented Oct 13, 2014 at 21:54

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.