Group Abstract Group Abstract

Message Boards Message Boards

Functions needed in Image Processing for future release of Mathematica

Update:

Some more desirable functions:

  • Superpixels

  • Graph cut segmentation: the "GrowCutComponents" in Mathematica uses cellular automata. Is the performance better than graph cut?

  • faster execution of Watershed components for 3D images for a considerable number of components.

  • built in functions (based on neural nets) that can be trained on datasets to do binary segmentation or semantic segmentation. Wolfram Neural Net repository nets can be made into special functions perhaps?

  • Interpolate between two binary images in 2D and 3D

Original Post

I am thrilled by the image processing capabilities built into Mathematica and witness its power on a daily basis. I never have to use any other program for image processing, save FIJI. In my opinion Mathematica's image processing core, albeit powerful and broad, can adopt a thing or two from FIJI. As a biophysics student - who works with microscopy images and other images in general - I firmly believe that the suggested functions mentioned below can further add a lot of punch to the image processing core. Furthermore, several of these functions have a role much broader than microscopy/fluorescence microscopy. I sincerely hope that the image processing development team takes a note of the post.

Please let me know in the comments section if some function already exists. And feel free to add functionalities to the list.

DESIRABLE FUNCTIONALITIES

POSTED BY: Ali Hashmi
15 Replies

I'm veering off-topic though.

I would, of course, like to see the image processing functionality improve too. I would like to see common tools be included as built-in functions.

My point was simply that there will always be many more tools that Wolfram won't have resources to include. Like you, I love to work in Mathematica, so I hope they'll make it as easy as possible to use Mathematica as a glue language and call other systems directly from Mathematica as needed. E.g. J/Link is already very good, but alone it's not enough.

POSTED BY: Szabolcs Horvát

I second you on this. For my current pipeline, I am doing registration using a plugin in ImageJ and then have to export all those images back to M. If there were an easier integration with other potentially powerful software then it will only make the pace of the work faster and seem a bit effortless.

The best approach then is thus two-pronged: (1) WRI should make it easier for M to interface with other programs (2) to extend the current capabilities of the core.

And I do hope that Charles Pooh is going to do what he said earlier that they are not abandoning Graph and associated functions. We are all aware how important graphs are - in their own right and as a useful data structure.

POSTED BY: Ali Hashmi

And btw if you deem so, would not it be nice to have a post where you can jote down all the Graph related functionality that you desire as an experienced user? I am interested to know what needs to be added to Graph. Maybe someone at WRI can take notes as to what the community desires.

POSTED BY: Ali Hashmi

Last off-topic message in this thread—if you have figured out a way to control ImageJ/Fiji from within Mathematica, even in a very rudimentary way, please do send me an email. We can continue the discussion there then.

POSTED BY: Szabolcs Horvát

I am still doing it very crudely and am myself trying to find a way to connect the two together. I will let you know if I get any success !

POSTED BY: Ali Hashmi
POSTED BY: Szabolcs Horvát
POSTED BY: Ali Hashmi
POSTED BY: Szabolcs Horvát

Btw this version of the function written by someone (forgot the name) is slow but sometimes I find it useful:

HistogramTransformationWeightedLocalAdaptive[img_, radius_] := 
  Module[{funs, nodes, w, h, f, fun, fi},
   funs = Map[HistogramTransformInterpolation, ImagePartition[img, {2*radius + 1}], {2}];
   {w, h} = ImageDimensions@img;
   nodes = Map[Mean@Flatten[N@ImageData[#, Automatic], 1] &, 
     ImagePartition[Image[Array[{#1, #2} &, {h, w}], "Bit16"], {2*radius + 1}], {2}];
   nodes = ArrayPad[nodes, {{1, 1}, {1, 1}}, "Fixed"];
   nodes[[All, {1, -1}, 2]] = {1, w};
   nodes[[{1, -1}, All, 1]] = {1, h};
   funs = ArrayPad[funs, 1, "Fixed"];
   fi = Interpolation[Thread[{Round@Flatten[nodes, 1], 
       Table[f[#], {f, Flatten@funs}]}], InterpolationOrder -> 1];
   fun[v_, {r_, c_}] := Evaluate[fi[r, c]] &[v];
   Quiet@ImageApplyIndexed[fun, img]
   ];

enter image description here

POSTED BY: Ali Hashmi

Thanks Ali for sharing your wish list. It really helps to hear user feedback. Most of these were already on our todo list, we will add the missing ones and reprioritize all of them.

Also, here are a few things from the list that are immediately possible:

  • Hough circles, as Sanders mentioned, we have the OpenCV version of it, it is waiting for a more complete/robust version that works in more cases
  • Strahler Analysis can be done with morphological operations, look at Pruning
  • morphological segmentation is the same as what we have under WatershedComponents
  • lookup table application to images is available through ImageApply. Typically, for integer images a LUT is created as the pixels are processed anyways. One can also provide a specific LUT.
POSTED BY: Shadi Ashnai

Thanks Shadi for taking note of the post. I am really looking forward to the new functionalities that you and your team will incorporate in the next release(s). I will also remove those features from my post that have already been implemented (e.g. Strahler Analysis and Morphological Segmentation) or at least mention that they are already there :)

POSTED BY: Ali Hashmi

Hi Shadi,

I made an update of the post: included super pixel, GraphCut segmentation and a possible faster execution for Watershed opponents for 3D.

Regards, Ali

POSTED BY: Ali Hashmi
  • Strahler Analysis can be done with morphological operations, look at Pruning

@Shadi, how would I select a certain branch, mark it as "the root", and prevent it from getting pruned by Pruning?

One way would be to manually add a small cycle, e.g. this pixel pattern, at the end of the branch:

0 1 0
1 0 1
0 1 0

This seems troublesome to automate though.

Talking of cycle, Fiji has a feature to prune small cycles with various methods. One way I can think of to achieve this in Mathematica is to negate the image, then DeleteSmallComponents. If there is a more efficient way that could be made part of Pruning, that would be a welcome extension.

POSTED BY: Szabolcs Horvát

i know that the first one is already there, albeit a bit hidden:

ClearAll[oFindImageCircles]
oFindImageCircles[img_/;ImageQ@img&&ImageChannels@img==1,
{sizemin_Integer,sizemax_Integer},(*range of radii for circles*)
mindist_Real,(*minimum distance in between circle centers*)
thrCanny_Real,(*minimum canny edge strength---the function computes edge detection on the input*)
thrStrength_Real,(*minimum strength of circle (aka votes)*)
resolutionfactor_,(*between 0 and 1,how big is the hough array compared to the image*)
nmax_  (*max number of circles*)
]:=Module[{res},Needs["OpenCVLink`"];
    res=OpenCVLink`Private`$HoughCircles[img,1/resolutionfactor,mindist,(255*thrCanny),thrStrength,sizemin,sizemax];(*sorted by strength already*)
    If[Head@res=!=List,Throw@$Failed];
        res={{#1,#2},#3}&@@@Partition[res,3];
        If[nmax===All,
            res,
            Take[res,UpTo[nmax]]
        ]
];
POSTED BY: Sander Huisman

Thanks Sander ! was really hidden :)

POSTED BY: Ali Hashmi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard