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.

problem with convert image to geometry with the function mphimage2geom in Matlab LiveLink

Please login with a confirmed email address before reporting spam

hello,

i was very happy to find that with the function 'mphimage2geom' provided in Matlab LiveLink it's possible to convert a grey scale image into geometry. It's quite cool. A comsol model can be generated with the function. then physics can be assigned to the geometry in the comsol model. But now my problem is that the functions sometime works, sometimes not.

Details about my problem: 2 images are attached here. the image named 'test_original.tif' can be directly converted into geometry without any problem. but with the image 'test_processed.tif' in which the empty space is filled in ImageJ , it doesn't work anymore. Matlab gives error message on matrix dimension problem. But the image dimension was not changed at all. Can someone help to explain where it goes wrong? Has anyone had this problem before?

Thank you!

Chunyan


8 Replies Last Post 28.03.2016, 01:19 GMT-4

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 08.04.2014, 05:18 GMT-4
I'm surprised to see COMSOL can handle such "geometry". It's really amazing... considering there are so many details, which more look like noise.

Curious to know more about it.
--
Pu, ZHANG
DTU Fotonik
I'm surprised to see COMSOL can handle such "geometry". It's really amazing... considering there are so many details, which more look like noise. Curious to know more about it. -- Pu, ZHANG DTU Fotonik

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 08.04.2014, 07:33 GMT-4

I'm surprised to see COMSOL can handle such "geometry". It's really amazing... considering there are so many details, which more look like noise.

Curious to know more about it.
--
Pu, ZHANG
DTU Fotonik


yes, you are right. there are too much details. this is just my first try. when I really do serious calculations later, which would be also quite simple, I should think about getting the boundary smoother.

Chunyan
[QUOTE] I'm surprised to see COMSOL can handle such "geometry". It's really amazing... considering there are so many details, which more look like noise. Curious to know more about it. -- Pu, ZHANG DTU Fotonik [/QUOTE] yes, you are right. there are too much details. this is just my first try. when I really do serious calculations later, which would be also quite simple, I should think about getting the boundary smoother. Chunyan

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 08.04.2014, 08:23 GMT-4
If those details don't make much difference in the physics, I think removing them will make the calculation smoother.

--
Pu, ZHANG
DTU Fotonik
If those details don't make much difference in the physics, I think removing them will make the calculation smoother. -- Pu, ZHANG DTU Fotonik

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 15.10.2015, 11:29 GMT-4
Hi,

I am having similar problems with select 2D images that I am trying to convert into geometries that are subsequently imported into COMSOL. By and large, most images that I am processing work fine, but every once in a while there are some that give the error message below. I am not sure the problem is related to the complexity of the image, given that they are all quite similar, and a VERY different data set I am using that is significantly more complicated has the same issues, although with greater frequency. I tried to upload a good image and a bad one for example, but the forum does not seem to allow attachments at this time. If anyone knows what the problem could be I would greatly appreciate some help with this closed source mphimage2geom function.

Attempted to access f(1); index out of bounds because numel(f)=0.

Error in mphimage2geom>creategeom (line 513)

Error in mphimage2geom (line 128)

Hi, I am having similar problems with select 2D images that I am trying to convert into geometries that are subsequently imported into COMSOL. By and large, most images that I am processing work fine, but every once in a while there are some that give the error message below. I am not sure the problem is related to the complexity of the image, given that they are all quite similar, and a VERY different data set I am using that is significantly more complicated has the same issues, although with greater frequency. I tried to upload a good image and a bad one for example, but the forum does not seem to allow attachments at this time. If anyone knows what the problem could be I would greatly appreciate some help with this closed source mphimage2geom function. Attempted to access f(1); index out of bounds because numel(f)=0. Error in mphimage2geom>creategeom (line 513) Error in mphimage2geom (line 128)

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 15.10.2015, 17:43 GMT-4
HI. Your problem may be resulted from 3 aspect:

1) The image which is not able to be input is not a square matrix (not NxN)
2) Your image may be 3 dimensional matrix ,which means the image is colorful.
you can use matlab code to transfer to 2 dimensions.

if ndims(I)==3
I=rgb2gray(I)
end
Where I is imread (...)
3) if your pixel matrix is a square matrix, your problem may be that your current geometric is occupying your Comsol Multiphysics. Save your current geometry and create a new model so that you can input your second image

Hopefully it is helpful to you

Regard CHI
HI. Your problem may be resulted from 3 aspect: 1) The image which is not able to be input is not a square matrix (not NxN) 2) Your image may be 3 dimensional matrix ,which means the image is colorful. you can use matlab code to transfer to 2 dimensions. if ndims(I)==3 I=rgb2gray(I) end Where I is imread (...) 3) if your pixel matrix is a square matrix, your problem may be that your current geometric is occupying your Comsol Multiphysics. Save your current geometry and create a new model so that you can input your second image Hopefully it is helpful to you Regard CHI

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 20.10.2015, 11:06 GMT-4
Hi Chi Chen,

Thanks for you suggestions, but none of the three options you describe are the case we are facing here. At best, the third option would be the most plausible, but uploading the geometry to COMSOL was not even possible because generating a geometry in the matlab interface is what is not working. It appears that watershedding the porous medium we are using for simulations fixes the problem most of the time, though it would be good to know why this type of data manipulation is required.

Thanks,

Veronica
Hi Chi Chen, Thanks for you suggestions, but none of the three options you describe are the case we are facing here. At best, the third option would be the most plausible, but uploading the geometry to COMSOL was not even possible because generating a geometry in the matlab interface is what is not working. It appears that watershedding the porous medium we are using for simulations fixes the problem most of the time, though it would be good to know why this type of data manipulation is required. Thanks, Veronica

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 17.11.2015, 12:19 GMT-5
Hi,

I got same error with my optical fiber geometries.
I have noticed that the problem appears when an object touching perimeter of image
has some holes inside.

Karol Tarnowski
Hi, I got same error with my optical fiber geometries. I have noticed that the problem appears when an object touching perimeter of image has some holes inside. Karol Tarnowski

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 28.03.2016, 01:19 GMT-4
Actually, I have got the detial steps for importing your image (SEM) into COMSOL, no matter how complex your image is. You can use "ImageJ; AI-CS4; Auto-CAD " for preprocessing your image separately. And the geometric modeling can be edited under your "Geometry" unit in your COMSOL software.

Actually, I have got the detial steps for importing your image (SEM) into COMSOL, no matter how complex your image is. You can use "ImageJ; AI-CS4; Auto-CAD " for preprocessing your image separately. And the geometric modeling can be edited under your "Geometry" unit in your COMSOL software.

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.