# Image processing in Matlab

**URL:** <https://discourse.slicer.org/t/image-processing-in-matlab/25572>\
**Category:** Support\
**Created:** [October 6, 2022, 1:40pm UTC](https://discourse.slicer.org/t/image-processing-in-matlab/25572 "2022-10-06T13:40:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaoloZaffino](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/paolozaffino/32/81052_2.png) [@PaoloZaffino](https://discourse.slicer.org/u/PaoloZaffino)\
**Post date:** [October 6, 2022, 1:40pm UTC](https://discourse.slicer.org/t/image-processing-in-matlab/25572/1 "2022-10-06T13:40:09Z")

</div>

Hi all,  
I have a matlab script that processes an image.  
I would like to load a volume in slicer, run the matlab script from slicer, and get the results back in matlab.  
Any example/idea of how to do this?

Thanks a lot,  
Paolo

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [October 6, 2022, 2:05pm UTC](https://discourse.slicer.org/t/image-processing-in-matlab/25572/2 "2022-10-06T14:05:29Z")

</div>

You could use [launchConsoleProcess](https://slicer.readthedocs.io/en/latest/developer_guide/slicer.html#slicer.util.launchConsoleProcess) to run your matlab script, but it will be a separate process and not have direct access to the volume you loaded into slicer. You would have to write out the volume in a format that can be ingested by your script, and then separately read in whatever the script wrote to disk.

There appears to be an extension [SlicerMatlabBridge](https://github.com/PerkLab/SlicerMatlabBridge) but IDK how up to date it is given that its [documentation](https://www.slicer.org/wiki/Documentation/Nightly/Extensions/MatlabBridge) is on the old wiki. It seems like this does what you want though

---

<div class="post-metadata">

**Author:** ![PaoloZaffino](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/paolozaffino/32/81052_2.png) [@PaoloZaffino](https://discourse.slicer.org/u/PaoloZaffino)\
**Post date:** [October 10, 2022, 10:23am UTC](https://discourse.slicer.org/t/image-processing-in-matlab/25572/3 "2022-10-10T10:23:50Z")

</div>

Thanks @ebrahim

@lassoan do you have any suggestions?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 10, 2022, 11:38am UTC](https://discourse.slicer.org/t/image-processing-in-matlab/25572/4 "2022-10-10T11:38:00Z")

</div>

The MatlabBridge extension sites exactly what you describe. It should still work. There are examples in its documentation.
