# How to use Dynamic and Setting inside a DynamicModule?

Consider an image (img) as

Using the following code I can dynamically change the value of t and see the updated components.

Manipulate[
bin = MorphologicalBinarize[img,{t[[1]],t[[2]]}];
Colorize[MorphologicalComponents[bin]],
{t, 0, 1}, ControlType -> IntervalSlider
]


I can switch to DynamicModule in the following way:

DynamicModule[{},
bin = Dynamic@MorphologicalBinarize[img, t];
c = Dynamic@Colorize[MorphologicalComponents[Setting@bin]];
{c, Dynamic@IntervalSlider[Dynamic[t]]}
]


So far this is fine. However, I have several other lines of codes followed by this inside DynamicModule and every time I need to apply Dynamic to get the updated result and when one result is to be applied to the next line I need to use Setting.

Do I need to use Dynamic at each operation and followed by Setting or is there any better way to avoid this?

• No, you do not need, DynamicModule[{}, c = Dynamic[ bin = MorphologicalBinarize[img, t]; Colorize[MorphologicalComponents[bin]] ]; {c, Dynamic@IntervalSlider[Dynamic[t]]}] – Kuba Feb 28 '18 at 20:57