Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a Manipulate[ ] that displays an image with a superimposed Locator object. It works fine when I have SaveDefinitions->False but when I try to change False to True the image object changes (and is not displayed correctly). Here's an image which I load in and call img

my tif image

The Manipulate is this:

 img = Import["http://i.stack.imgur.com/xKudh.png"];
 Manipulate[img, {p, Locator}, SaveDefinitions -> False]

If you evaluate this, it displays the image with a locator object in the bottom left. All is well. But if you now evaluate

 Manipulate[img, {p, Locator}, SaveDefinitions -> True]

it displays not the image, but a long list of numbers starting with:

Image[{{244,243 ....

In trying to debug, I note that ImageQ[img] is True after evaluating the first Manipulate but is False after evaluating the second. This does not occur with all images (I tried a jpeg) but seems to happen with my .tif files (like the one above). Mathematica 9.0.1 Mac OS. I just noticed that when I uploaded the image, it was converted to a .png file. The same (bad) behavior occurs with this file as well.

share|improve this question
    
Both Manipulates work for me in 8.0.4 on Windows 7. –  Eric Thewalt Mar 20 '13 at 7:28
    
Both work fine on my installation -- V9.0.1 running on OS X (10.6.8) –  m_goldberg Mar 20 '13 at 8:11
    
m_goldberg Wow... that's weird. I just tried (again) with a new launch and it's still happening -- though my system seems identical to yours. Thanks for checking. –  bill s Mar 20 '13 at 8:20
    
I see no difference PC WinXP, Math 9.0.1.0 –  Alexei Boulbitch Mar 20 '13 at 8:20
    
I can reproduce this behaviour. 9.0.1 on OS X 10.8.3. When SaveDefinitions is set to True, the structure of img is changed from Image[RawArray["Byte",{{... to Image[{{...}}, Byte, ColorSpace -> ..., Interleaving -> ...]. I have no idea why the symbol img is modified. –  rm -rf Mar 20 '13 at 8:21
show 4 more comments

2 Answers

up vote 4 down vote accepted

Try this:

img = Image@ImageData@Import["http://i.stack.imgur.com/xKudh.png"];
Manipulate[img, {p, Locator}, SaveDefinitions -> True]

or this

img = Import["http://i.stack.imgur.com/xKudh.png"];
Manipulate[
 img = Quiet[img /. ColorProfileData[] -> Automatic], {p, Locator}, 
 SaveDefinitions -> True]

I think the problem is how the image is stored when it is imported. I do not know anything about this, so perhaps others better versed in image processing will know what it is. Here is an image of the FullForm of Import["http://i.stack.imgur.com/xKudh.png"]:

FullForm

When Manipulate converts it to some saved format, it must mangle the ColorSpace option. It gets converted to ColorSpace -> ColorProfileData[], which is invalid. Setting it to Automatic seems to work, except that in generates a message somewhere in the Manipulate; hence the Quiet.

It seems to be a bug, but in the meantime, you have a workaround.

share|improve this answer
    
thanks for this. It's just happened to me again, and your ColorProfileData fix works perfectly. –  bill s May 25 '13 at 5:18
add comment

This isn't really an answer, but I sent the question to Wolfram. They replied:

The problem reported by you about SaveDefinitions option with Manipulate was reproducible. It has been forwarded to the development team for further investigation. You will be informed via email when it gets fixed.

I'll report back here if they respond.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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