cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Showing a different jpg image depending on a result (MathCAD 15.0)

ClaudioPedrazzi
12-Amethyst

Showing a different jpg image depending on a result (MathCAD 15.0)

Hi everyone,

I would like to show a different jpg image depending on a certain result.

Say for example that I have three sketches, saved in the active directory:

sketchA.jpg

sketchB.jpg

sketchC.jpg

The three sketches have similar but not perfectly identical pixel number. 

I perform a certain calculation, that e.g. produces x as a result.

Is it possible, using for example a conditional READ_IMAGE(), to let appear e.g. sketchA if x<=0, sketchB if 0<x<1 and sketchC if x>=1 ?

I am actually using MathCAD 15.0.  But would this functionality be available also in MathCAD Prime?

How would you implement this functionality?

Thanks a lot for any hint

Best regards

Claudio

ACCEPTED SOLUTION

Accepted Solutions


@ClaudioPedrazzi wrote:

Hi everyone,

I would like to show a different jpg image depending on a certain result.

Say for example that I have three sketches, saved in the active directory:

sketchA.jpg

sketchB.jpg

sketchC.jpg

The three sketches have similar but not perfectly identical pixel number. 

I perform a certain calculation, that e.g. produces x as a result.

Is it possible, using for example a conditional READ_IMAGE(), to let appear e.g. sketchA if x<=0, sketchB if 0<x<1 and sketchC if x>=1 ?

I am actually using MathCAD 15.0.  But would this functionality be available also in MathCAD Prime?

How would you implement this functionality?

Thanks a lot for any hint

Best regards

Claudio


Yes, it's straightforward in Mathcad 15 - indeed, there are several ways to skin the selection cat.

 

Unfortunately, I don't have Mathcad 15 so can't give a programmed example, but the following Mathcad Prime example should work in M15.

 

2022 04 19 a.png

 

You insert a Picture operator into your worksheet and type img(x) into the placeholder. 

 

As for Prime, ... in one of the more annoying exclusions (I've complained about since Prime 1), it is not possible to load an arbitrary image into a worksheet.   That capability is a candidate for some future version of Prime, according to the last published roadmap.

 

https://community.ptc.com/t5/PTC-Mathcad/PTC-Mathcad-Prime-Roadmap-2021-update/m-p/738684

 

Stuart

View solution in original post

6 REPLIES 6


@ClaudioPedrazzi wrote:

Hi everyone,

I would like to show a different jpg image depending on a certain result.

Say for example that I have three sketches, saved in the active directory:

sketchA.jpg

sketchB.jpg

sketchC.jpg

The three sketches have similar but not perfectly identical pixel number. 

I perform a certain calculation, that e.g. produces x as a result.

Is it possible, using for example a conditional READ_IMAGE(), to let appear e.g. sketchA if x<=0, sketchB if 0<x<1 and sketchC if x>=1 ?

I am actually using MathCAD 15.0.  But would this functionality be available also in MathCAD Prime?

How would you implement this functionality?

Thanks a lot for any hint

Best regards

Claudio


Yes, it's straightforward in Mathcad 15 - indeed, there are several ways to skin the selection cat.

 

Unfortunately, I don't have Mathcad 15 so can't give a programmed example, but the following Mathcad Prime example should work in M15.

 

2022 04 19 a.png

 

You insert a Picture operator into your worksheet and type img(x) into the placeholder. 

 

As for Prime, ... in one of the more annoying exclusions (I've complained about since Prime 1), it is not possible to load an arbitrary image into a worksheet.   That capability is a candidate for some future version of Prime, according to the last published roadmap.

 

https://community.ptc.com/t5/PTC-Mathcad/PTC-Mathcad-Prime-Roadmap-2021-update/m-p/738684

 

Stuart

Hi Stuart

thanks a lot!

it seems to work similarly also in MathCAD 15.0 (using READ_IMAGE or READRGB), the only problem is, notwithstanding the statement in the help, that "recognized image formats are BMP, GIF, JPG, PCX, or TGA.", I was able to get the wished result only using GIF. Actually I would like to use jpg.  But I get the message "unknown file format" with .jpg and .JPG too.

Does some user know how to read JPG files in MathCAD 15.0?

Thanks a lot again

Regards

Claudio

Hi,

Mathcad 15 is older software so has not kept up with advances in the jpeg format.

The enclosed photo of a guitar was taken with an Ipad to jpg format.

It has been scaled down in GIMP so can be uploaded here.

I use the free photo editor GIMP to remove the modern color profile.

https://www.gimp.org/downloads/

 

Not sure but it may be possible to open the modern jpg with the default photo editor in windows and simply Save As a new jpg.  This may also get rid of modern color profiles

 

Screenshot 2022-04-20 000052.JPG

 

Hi Stuart and Terry,

thanks for the hints.  For some reason I didn't manage to obtain stable results with jpg. Some images (color and b/w) were readable, other not! Of course all of them were made with the same tool, namely the "Snipping Tool" of Windows, and about the same pixel dimensions.

The GIF format seemed to work better.  So my actual solution looks like this, in the most simple form:

Unbenannt.PNG

 

of course "type" is a string but it would not be a problem to build it depending on a result. My point in the question was if it was possible to have a variable picture, for example to illustrate different geometrical configurations.  Of course the "price to pay" is to have the collection of GIF-files stored in the active directory (or somewhere else).

 

Thanks a lot everyone

Best regards

Claudio


Of course the "price to pay" is to have the collection of GIF-files stored in the active directory (or somewhere else).

Not necessarily! You can read in the images once when creating the worksheet and then store the matrix permanently in the worksheet via Insert-Data-Table. Of course, this will make the file larger, but no external extra files are needed any more.

 

EDIT: Find attached an example

Of course normally you would hide the arguments of the list box and the picture region and the definition of the matrices could be hidden in a collapsed area.

Werner_E_0-1650449435844.png

 

 


@ClaudioPedrazzi wrote:

Hi Stuart and Terry,

thanks for the hints.  For some reason I didn't manage to obtain stable results with jpg. Some images (color and b/w) were readable, other not! Of course all of them were made with the same tool, namely the "Snipping Tool" of Windows, and about the same pixel dimensions.

The GIF format seemed to work better.  So my actual solution looks like this, in the most simple form:

Unbenannt.PNG

 

of course "type" is a string but it would not be a problem to build it depending on a result. My point in the question was if it was possible to have a variable picture, for example to illustrate different geometrical configurations.  Of course the "price to pay" is to have the collection of GIF-files stored in the active directory (or somewhere else).


Given those images have to be somewhere, another option for type selection might be to pick the image from a grid. 

 

You could even make a game of it ... https://community.ptc.com/t5/PTC-Mathcad/Toads-and-Frogs/m-p/193572#M75890

 

Stuart

Announcements

Top Tags