imglib / imglib2-roi

Regions of interest (ROIs) and labelings for ImgLib2
Other
8 stars 8 forks source link

Ordering of labels in LabelRegions #14

Closed dietzc closed 9 years ago

dietzc commented 9 years ago

Hi @tpietzsch,

I just ran into problems in another scenario where the ordering of the returned value so a hashMap.keySet() call changed from Java 1.7 to 1.8, in case that the type of your key is String. I quickly checked your implementation at https://github.com/imglib/imglib2-roi/blob/master/src/main/java/net/imglib2/roi/labeling/LabelRegions.java#L108 and here you also just use a HashMap so this problem may be present in case someone calls https://github.com/imglib/imglib2-roi/blob/master/src/main/java/net/imglib2/roi/labeling/LabelRegions.java#L130.

If you want to address this problem in imglib2-roi, we could use a LinkedHashMap instead of a simple HashMap.

Does this make sense?

tpietzsch commented 9 years ago

@dietzc I don't understand the problem. Why should the Keyset be ordered?

dietzc commented 9 years ago

@tpietzsch we have implemented two algorithms of which the output depends on the ordering of the incoming labels. Actually, the result is still the same if the labels have different ordering, but the naming of the labels then differs (which makes regression tests hard). However, while writing it appears to me that this is something we should handle on our side, e.g. by sorting the labels on our own. Right?

Have a nice sunday!

tpietzsch commented 9 years ago

@dietzc Yes, you should sort the labels on your end if the order is important.