Message Boards Message Boards

0
|
8692 Views
|
8 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Using an image as a variable for integrating

Posted 10 years ago

In v7 it was allowed to integrate (derive, etc.) using images as variables. I loved that funcionality because, literally, let me show my students how to integrate with little apples. This is a screenshot from v7:

Integration with image v7

Now I'm using v9, but when I try to integrate this way, the result is this:

Integration with image v9

Does anyone know, first, why this backward step?, and second, is there a way to get back that funcionality? Thanks

POSTED BY: Daniel Solis
8 Replies

I was goofing around, apologies. The reference, such as it was, was to the powers to which the apples appeared.

POSTED BY: Daniel Lichtblau

So, the Image head (from the drag or copy/past) is not treated by the Integrate in the same way as the graphics head (from the Rasterize). I imagine this is just something that was overlooked on the language unification, and that it could be improved on future versions. Right?

POSTED BY: Pedro Fonseca

It certainly seems so since one can integrate something with an arbitrary head with respect to such a thing and get the expected answer. E.g.,

Integrate[f[z]^2, f[z]]

gives

( f[z]^3)/3

But

img=Image[ConstantArray[.4, {4, 4}]]

gives the noted error when tried with

Integrate[img^2, img]

If however we recognize that img is the same as

f[{{0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 
   0.4}, {0.4, 0.4, 0.4, 
    0.4}}, "Real", ColorSpace -> Automatic, Interleaving -> None]

and try the obvious (but unwieldy) expression (i.e., replacing Image by an arbitrary undefined head f)

Integrate[
 f[{{0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 
    0.4}, {0.4, 0.4, 0.4, 
     0.4}}, "Real", ColorSpace -> Automatic, Interleaving -> None]^2, 
 f[{{0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 
    0.4}, {0.4, 0.4, 0.4, 
     0.4}}, "Real", ColorSpace -> Automatic, Interleaving -> None]]

we get the expected (ugly) result

1/3 f[{{0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 0.4}, {0.4, 0.4, 0.4, 
    0.4}, {0.4, 0.4, 0.4, 0.4}}, "Real", ColorSpace -> Automatic, 
  Interleaving -> None]^3

So, yes, it seems a bug.... ;-)

I sent in a report....

POSTED BY: David Reiss
Posted 10 years ago
POSTED BY: Itai Seggev

It seems your apples went from cubes to quarts. Was this a packing problem?

POSTED BY: Daniel Lichtblau

Daniel, sorry, I don't understand what "go from cubes to quarts" means. I suppose it's something about that the images are different. They are different only because I had not the original apple to show, but unfortunately it has nothing to do if the image is realistic or a draw.

POSTED BY: Daniel Solis

Probably this is because of the new Image processing functionality in Mathematica 9 and 10.

However I found that you can regain the sort of thing you want to do by first Rasterizing the image that you are starting with and then using that rasterized version.

Give it a try and let me know if it works for you.

POSTED BY: David Reiss

You are right, rasterizing the image first works fine. Too bad I have to do it prior the integration (I liked just dropping images), but, it works, good enough.

Thanks!

POSTED BY: Daniel Solis
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract