Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

import a bmp image into COMSOL geometry

Please login with a confirmed email address before reporting spam

Hey,

as stated in this webpage: www.comsol.com/products/formats/ Comsol can both read and write few types of images. However, when I tried to import a bmp image as my structure for flow simulation, it was not possible, because the options given include only mphtxt, dxf, etc. Does any one know how I can get a bmp or jpeg image imported? Thanks!

Chunyan

20 Replies Last Post 13.03.2017, 09:20 GMT-4

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.02.2012, 10:40 GMT-5

I don't think it possible to set up a model geometry (is that what you want?) from a bitmap.

Cheers
Edgar
I don't think it possible to set up a model geometry (is that what you want?) from a bitmap. Cheers Edgar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.02.2012, 11:14 GMT-5
Hey Edgar,

yes, it is, because the biofilm structure I need is very complicated. It's neither possible nor reliable to draw it with any software. I want to use the image I got from OCT analysis.

Do you know if it's possible to import txt files? The results can also be saved in txt files.

Thanks!

Chunyan


Hey Edgar, yes, it is, because the biofilm structure I need is very complicated. It's neither possible nor reliable to draw it with any software. I want to use the image I got from OCT analysis. Do you know if it's possible to import txt files? The results can also be saved in txt files. Thanks! Chunyan

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.02.2012, 11:20 GMT-5
Hi Chunyan,

I think you must render the bitmap into a compatible vector format. This may be dxf or one of the available interfaces for CAD software like SolidWorks. I don't know what can be imported by textfiles. Maybe the COMSOL support can help.

However, very complicated biological structures will result in complicated geometries that are difficult to mesh and solve.

My advice would be to draw something simplified and start with it.

Cheers
Edgar
Hi Chunyan, I think you must render the bitmap into a compatible vector format. This may be dxf or one of the available interfaces for CAD software like SolidWorks. I don't know what can be imported by textfiles. Maybe the COMSOL support can help. However, very complicated biological structures will result in complicated geometries that are difficult to mesh and solve. My advice would be to draw something simplified and start with it. Cheers Edgar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.02.2012, 11:47 GMT-5
Hello Edgar,

thank you very much for your suggestions. I've just checked that it's possible to convert bmp images into dxf format. Will try that out. Thanks!!!!!

Regards!

Chunyan
Hello Edgar, thank you very much for your suggestions. I've just checked that it's possible to convert bmp images into dxf format. Will try that out. Thanks!!!!! Regards! Chunyan

Saeid Norouzi Apourvari

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15.10.2012, 20:17 GMT-4
Hi Chunyan,

Did you succeed to simulate flow on converted file. I converted a .png file to DXF file and imported to COMSOL. However at the end the solution does not converge. I think we have the same problem, since I am also trying to simulate flow on image acquired from CT. Please let me know if you have found a solution.

Regards,
saeid
Hi Chunyan, Did you succeed to simulate flow on converted file. I converted a .png file to DXF file and imported to COMSOL. However at the end the solution does not converge. I think we have the same problem, since I am also trying to simulate flow on image acquired from CT. Please let me know if you have found a solution. Regards, saeid

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.10.2012, 04:02 GMT-4
hello Saeid,

i did succeed in doing flow simulation with image imported. First right click on "Definition" under your model, select "Functions"--->"Image", then import image, define the scale of your image.

Afterwards you may need to define different viscosity for the bulk liquid and for the image part. it is done: right click on "Definition", select "Functions"---->"Analytic", in the "Expression" text box, you can define different properties corresponding to the gray level.

in my case, it is water and i used binary image. it is defined as: mu*(im2(x,y)<0.1)+mu*1e9*(im2(x,y)>=0.1) i consider that there is no water flow in the space occupied by the image. so i gave viscosity of the image part with 1e9 times higher than the area not occupied by the image. in this way, you can also define other properties simply by correcting them to the gray value.

Hope it can help you a little bit.

Chunyan :)
hello Saeid, i did succeed in doing flow simulation with image imported. First right click on "Definition" under your model, select "Functions"--->"Image", then import image, define the scale of your image. Afterwards you may need to define different viscosity for the bulk liquid and for the image part. it is done: right click on "Definition", select "Functions"---->"Analytic", in the "Expression" text box, you can define different properties corresponding to the gray level. in my case, it is water and i used binary image. it is defined as: mu*(im2(x,y)=0.1) i consider that there is no water flow in the space occupied by the image. so i gave viscosity of the image part with 1e9 times higher than the area not occupied by the image. in this way, you can also define other properties simply by correcting them to the gray value. Hope it can help you a little bit. Chunyan :)

Saeid Norouzi Apourvari

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.10.2012, 20:34 GMT-4
Hi Chunyan,

Thanks for your reply.
You saeid you imported a binary image (segmented image). May I ask about the format of your original and the imported image? Is it 2D or 3D? I converted a 2D .png image of a sphere pack to .DXF but there are some artifacts in converted image which I think are the main reasons for divergence. Would you please advise me on that?

Best regards,
saeid
Hi Chunyan, Thanks for your reply. You saeid you imported a binary image (segmented image). May I ask about the format of your original and the imported image? Is it 2D or 3D? I converted a 2D .png image of a sphere pack to .DXF but there are some artifacts in converted image which I think are the main reasons for divergence. Would you please advise me on that? Best regards, saeid

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18.10.2012, 10:23 GMT-4
Hello Saeid,

i did 2D simulation. 3D is my next goal. i am working on that. I don't know how to convert image into geometry. A friend just told me yesterday that it's possible to do it with Matlab. But i don't know how to do it yet because i am very bad at programming. If you are good at that, you may try to do it with matlab.

Good luck!

Chunyan
Hello Saeid, i did 2D simulation. 3D is my next goal. i am working on that. I don't know how to convert image into geometry. A friend just told me yesterday that it's possible to do it with Matlab. But i don't know how to do it yet because i am very bad at programming. If you are good at that, you may try to do it with matlab. Good luck! Chunyan

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 02.11.2012, 16:54 GMT-4
Please let us know of your progress in 3D...
Please let us know of your progress in 3D...

Saeid Norouzi Apourvari

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30.01.2013, 04:07 GMT-5
Dear Chunyan,

I hope everything is going well with you.
I was reviewing some previous posts, looking for a possble way to export a segmented image to COMSOL as a geometry and not as a mesh. I came through this posted by you:

"i did succeed in doing flow simulation with image imported. First right click on "Definition" under your model, select "Functions"--->"Image", then import image, define the scale of your image. "

I was going to try this method for a 2D image, but I could not find "image" under "function" in definition node. Which COMSOL version you were talking about?

By the way, have you succeeded to export 3D image as a geometry to COMSOL?
I used Simpleware software and generated mesh from my 3D image and exported to COMSOL. It worked nice but for larger size of images you need lots of RAM to generate mesh and I could not do that with Simpleware and that is why I am trying to export my image to COMSOL as a geometry and let COMSOL mesh it for simulation.

Regrads,
Saeid
Dear Chunyan, I hope everything is going well with you. I was reviewing some previous posts, looking for a possble way to export a segmented image to COMSOL as a geometry and not as a mesh. I came through this posted by you: "i did succeed in doing flow simulation with image imported. First right click on "Definition" under your model, select "Functions"--->"Image", then import image, define the scale of your image. " I was going to try this method for a 2D image, but I could not find "image" under "function" in definition node. Which COMSOL version you were talking about? By the way, have you succeeded to export 3D image as a geometry to COMSOL? I used Simpleware software and generated mesh from my 3D image and exported to COMSOL. It worked nice but for larger size of images you need lots of RAM to generate mesh and I could not do that with Simpleware and that is why I am trying to export my image to COMSOL as a geometry and let COMSOL mesh it for simulation. Regrads, Saeid

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 21.04.2015, 06:18 GMT-4
Hi I have SEM report which is in jpg format these image has to be imported to the comsol so that i have to define material . it is a composite of two material, i am finding thermal residual stress on it,,please tell me how to proceed. and how i can change the temparature parameter.


Hi I have SEM report which is in jpg format these image has to be imported to the comsol so that i have to define material . it is a composite of two material, i am finding thermal residual stress on it,,please tell me how to proceed. and how i can change the temparature parameter.

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 21.04.2015, 06:20 GMT-4
Hi I have SEM report which is in jpg format these image has to be imported to the comsol so that i have to define material . it is a composite of two material, i am finding thermal residual stress on it,,please tell me how to proceed. and how i can change the temparature parameter.


files are attaached
Hi I have SEM report which is in jpg format these image has to be imported to the comsol so that i have to define material . it is a composite of two material, i am finding thermal residual stress on it,,please tell me how to proceed. and how i can change the temparature parameter. files are attaached


Gunnar Andersson COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 21.04.2015, 07:51 GMT-4
You can define an Image function and use the value from it when setting up your physics.
You can define an Image function and use the value from it when setting up your physics.

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 21.04.2015, 10:50 GMT-4
On the subject of JPEG: it's dangerous because JPEG contains compression artifacts: anomalous oscillations in intensity near edges. PNG is better. But you can trivially convert between image types with a suitable software, for example "ImageMagick" tools, in particular "convert", does it quickly and effectively. Then you don't need to worry any more about JPEG load-save cycles causing further degradation to your data.

I'm very interested in this subject myself. In computer graphics, for example POV-Ray, there's the notion of a "bump map" which perturbs surfaces along their normal using an image. In POV-Ray it's done using a linear perturbation applied to the scattering direction of light. But it could also be applied to a displacement field. The challenge is mapping a 2-dimensional image to a 3-dimensional surface. For example maps between a 2-dimensional map and the near-spherical earth surface is a nontrivial topic.

Anyway, I'd just convert the images to PNG.
On the subject of JPEG: it's dangerous because JPEG contains compression artifacts: anomalous oscillations in intensity near edges. PNG is better. But you can trivially convert between image types with a suitable software, for example "ImageMagick" tools, in particular "convert", does it quickly and effectively. Then you don't need to worry any more about JPEG load-save cycles causing further degradation to your data. I'm very interested in this subject myself. In computer graphics, for example POV-Ray, there's the notion of a "bump map" which perturbs surfaces along their normal using an image. In POV-Ray it's done using a linear perturbation applied to the scattering direction of light. But it could also be applied to a displacement field. The challenge is mapping a 2-dimensional image to a 3-dimensional surface. For example maps between a 2-dimensional map and the near-spherical earth surface is a nontrivial topic. Anyway, I'd just convert the images to PNG.

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 21.04.2015, 11:37 GMT-4
Hello Devendrakumar,

there are two ways to work with images in COMSOL.

The first one is to using image function as Gunnar said. It is described in previous answers.

The second one needs Matlab LiveLink. If you do have that module, check how to use the function "mphimage2geom' in the user guide. The function can convert your image into geometry. It supports quite some image formats. So then you can assign a lot of different properties to your geometry, which is not possible with the first method. There is example how to use the function in the user guide. Especially in the end when you want to calculate something, for example boundary flux, it is possible with this method, but not the first one.

To your specific question, I am very bad in thermal dynamics. Can't really give any tip for your specific question. Sorry for that. Hope this will somehow help you a little bit.
Hello Devendrakumar, there are two ways to work with images in COMSOL. The first one is to using image function as Gunnar said. It is described in previous answers. The second one needs Matlab LiveLink. If you do have that module, check how to use the function "mphimage2geom' in the user guide. The function can convert your image into geometry. It supports quite some image formats. So then you can assign a lot of different properties to your geometry, which is not possible with the first method. There is example how to use the function in the user guide. Especially in the end when you want to calculate something, for example boundary flux, it is possible with this method, but not the first one. To your specific question, I am very bad in thermal dynamics. Can't really give any tip for your specific question. Sorry for that. Hope this will somehow help you a little bit.

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 12.05.2015, 08:57 GMT-4
hello Li Chunyan,

i read u did succeed the process of SEM into Comsol, how?can i get in touch with u
hello Li Chunyan, i read u did succeed the process of SEM into Comsol, how?can i get in touch with u

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 12.06.2016, 23:59 GMT-4
Hello Chunyan,

mphimage2geom cammond unforunatly only works for 2D geometry. If I want to do 3D, do you know how? I have several MRI images and I want COMSOL to plot them in 3D.

Thank you!

Fei
Hello Chunyan, mphimage2geom cammond unforunatly only works for 2D geometry. If I want to do 3D, do you know how? I have several MRI images and I want COMSOL to plot them in 3D. Thank you! Fei

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 24.10.2016, 22:45 GMT-4
What programs did you use to convert png files into dxf format?

i have an X-ray CT image, and binarized it using imagej.
Exportable image formats are png, jpg etc... but comsol cannot import them directly.
Therefore I imported them to Autocad and exported it to dxf files, it still did not work out.
What programs did you use to import those grey scale value?
Would my binarized images work fine with your method?
What programs did you use to convert png files into dxf format? i have an X-ray CT image, and binarized it using imagej. Exportable image formats are png, jpg etc... but comsol cannot import them directly. Therefore I imported them to Autocad and exported it to dxf files, it still did not work out. What programs did you use to import those grey scale value? Would my binarized images work fine with your method?

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 20.01.2017, 05:13 GMT-5
Hi

Can you please tell how did you import dxf file in geometry.

Thanks..
Hi Can you please tell how did you import dxf file in geometry. Thanks..

Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 13.03.2017, 09:20 GMT-4
Hello Nisha,
2D dxf files can be imported with just the core COMSOL Multiphysics.
For 3D dxf files, you will need to have one of the optional COMSOL products for CAD import.
See the CAD Specification Chart www.comsol.com/products/specifications/cad/ for more details.
Best regards,
Jeff
Hello Nisha, 2D dxf files can be imported with just the core COMSOL Multiphysics. For 3D dxf files, you will need to have one of the optional COMSOL products for CAD import. See the CAD Specification Chart https://www.comsol.com/products/specifications/cad/ for more details. Best regards, Jeff

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.