# Is there any way to speed up this image manipulator?

This post is only a part of a broader analysis that I am performing on the image processing speed, but I think it's interesting in itself. I will post more in the next days. Now the problem is: I have a lot of images like this one

and I want straighten each of them. Obiously the rotation angle is not the same for all picture. To choose the correct one I have tried this:

numberFormat[arg_] := NumberForm[arg, {3, 3}, NumberSigns -> {"+", "-"}];
file = "c:\\degiorgi\\002\\z001.bmp";
img = Import[file, "BMP"];
Manipulate[
ImageRotate[img, -t],
Control[{{t, 0, Dynamic[numberFormat[t]]}, 0, 1, .1,
ControlType -> Slider}]
]


It works fine on little test images but grows deadly slow as image size increases and even to move the slider become practically impossibile. The same holds for

file = "c:\\degiorgi\\002\\z001.bmp";
img = Import[file, "BMP"];
r = Table[a, {a, 0, .5, .001}];
Manipulate[
ImageRotate[img, -t]
, Control[{t, r, ControlType -> PopupMenu}]
]


What am I doing wrong ? I think that all this is not affected by the machine performance because other image processing software, and vector drawing also, run fast.

In this specific case a possible workaround could be to process only the upper part of the image, but the main problem endures.

• Look this – yode Mar 28 '16 at 8:59

The issue is that you are rotating the full resolution Image at every "step". You can manipulate a thumbnail and apply the transformation to the full image afterwards.

numberFormat[arg_] :=  NumberForm[arg, {3, 3}, NumberSigns -> {"+", "-"}];

(* Get the full image *)
file = "http://i.stack.imgur.com/rYS4s.jpg";
img = Import[file];

(* Resize to 250 pixels*)
tmb = Thumbnail[img, 250];

Manipulate[
Column[
{ImageRotate[tmb,-t],
Button["Save",Print[ImageRotate[img,-t]]]}
],
Control[{{t,0,Dynamic[numberFormat[t]]},0,1,.1,ControlType->Slider}]
]


• Your hint fully solves my problem, thanks ! When are involved colorful images may be useful to compose Binarize and Thumbnail. I'm going to try. – mitochondrial Mar 28 '16 at 16:40