Message Boards Message Boards

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

Using an image as a variable for integrating

Posted 11 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

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

POSTED BY: Daniel Lichtblau

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

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

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

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

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

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

POSTED BY: Daniel Lichtblau
Posted 11 years ago

It is not exactly a bug. V7 used an early version of the Image object which just piggy backed on top of Graphics. Starting in V9, the image became a fully native type, like Integer, String, and Graph, and as a consequence it became AtomQ. Integrate generally considers AtomQ expressions other than symbols as not valid variables. You can't integrate with respect to 2 or "hello world". Theoretically, Integrate could be made to recognize Image as a variable, but the wisom and consequences of such a change are are unclear. So we cannot promise that this will be changed in a future version, but it will of course be considered along with other feedback regarding integrate.

(The rasterize version works for a rather different and not particularly relevant reason: because people have many different conventions for naming their variables, including x1, x[2], and Subscript[x,3], Integrate generally considers anything expression of the f[args___] family to be a vaid variable as f does not have attribute NumericFunction. This allows things like Subscript[x,3] while disallowing nonsensical expressions like x+y or Sin[x]. Because Rasterize produces a Graphics object, it just happens to work by accident--like the old image object--as Graphics is not NumericFunction.)

POSTED BY: Itai Seggev
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