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
Posted 2014年4月8日 GMT+8 13:31 Computational Fluid Dynamics (CFD) Version 5.1 8 Replies
Please login with a confirmed email address before reporting spam
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
Attachments:
Please login with a confirmed email address before reporting spam
Curious to know more about it.
--
Pu, ZHANG
DTU Fotonik
Please login with a confirmed email address before reporting spam
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
Please login with a confirmed email address before reporting spam
--
Pu, ZHANG
DTU Fotonik
Please login with a confirmed email address before reporting spam
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
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
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
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
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.
Suggested Content
- FORUM Export animation/image sequence via Matlab Livelink
- FORUM function from Image
- KNOWLEDGE BASE COMSOL Does Not Start with the Latest MATLAB Version
- BLOG Optimizing the Geometry of Optical Antennas with Genetic Algorithms
- KNOWLEDGE BASE Update for LiveLink™ for MATLAB® on macOS with Apple Silicon Processors Applicable to COMSOL Multiphysics® Version 6.2
