# DynamicImage with a Dynamic

This is probably a very simple thing, but I could not figure it out.

I am trying to create a window were I can display an image while being able to zoom, pan and scroll while adjusting contrast and brightness dynamic way.

In the simplified example below I can have the two parts separately:

img = ExampleData[{"TestImage", "House"}];
sliderC = Slider[Dynamic[c], {-5, 5, .01}, Appearance -> "Labeled"]
sliderB = Slider[Dynamic[b], {-5, 5, .01}, Appearance -> "Labeled"]
dynamicImg = DynamicImage[img]


But

final = DynamicImage[adjustedImg]


Cannot work because the argument of the function at this point is not an image any more

And if I use Setting to retrieve the image in the dynamic adjusted image, then final2 is not dynamically updated any more

final2 = DynamicImage[Setting[adjustedImg]]


I tried to use Pane instead of DynamicImage, but I could only set scrollbars and not the zoom (and I really need it).

Thank you for the help

• – Kuba Feb 19 '18 at 19:47

When I tried to do something similar I ended up creating my own version of DynamicImage. It was easier in the end. Here's the code I used, I'm sure it can be easily modified to meet your needs:

DynamicModule[{img2, mag = 1,
img = ExampleData[{"TestImage", "House"}], left = 0, right = 0,
bottom = 0, top = 0, dim},
dim = ImageDimensions[img];
Column[{
Grid[{
{"Magnification: ",
Row[{Button["-", If[mag > .1, mag = mag - .1, mag = .1]],
Button["+", If[mag < 2, mag = mag + .1, mag = 2]]}],
Dynamic[mag]},
{"Left: ", Slider[Dynamic[left], {0, -dim[[1]]/2 + 1}],
Dynamic[left]},
{"Right: ", Slider[Dynamic[right], {0, -dim[[1]]/2 + 1}],
Dynamic[right]},
{"Top: ", Slider[Dynamic[top], {0, -dim[[2]]/2 + 1}],
Dynamic[top]},
{"Bottom: ", Slider[Dynamic[bottom], {0, -dim[[2]]/2 + 1}],
Dynamic[bottom]}
}],