Comments (21)
from connected-components-3d.
Will, Thanks for your prompt response.
I dont have much idea on the type of the binvox output but I found this piece of information on their website which I assume might provide some information about this subject matter.
"The binary voxel data
The binary data consists of pairs of bytes. The first byte of each pair is the value byte and is either 0 or 1 (1 signifies the presence of a voxel). The second byte is the count byte and specifies how many times the preceding voxel value should be repeated (so obviously the minimum count is 1, and the maximum is 255)."
The binvox files have its own reader which can be found here 'https://github.com/dimatura/binvox-rw-py'
As for my code, I use the binvox-rw file to unpack the binvox file data and use the binary voxel information for classification. The reason I am looking to see if I can use your CCL application is to do a multiclass segmentation to further classify individual features from the voxelized files. After doing the CCL, I intend to use the watershed segmentation to classify individual features.
Ali
from connected-components-3d.
from connected-components-3d.
Will,
Please find attached a zip file containing a couple of binvox files to test the connectivity labeling code named 'Test.py'. I have attached 3 binvox files for your reference and the binvow_rw file that will help read and unpack the binvox files. As you might see in the Test.py, I have used your code snippet from Pypi as is with a couple of lines at the beginning to just read the binvox files using the binvow_rw.
I hope this is what you were looking for,
Ali
from connected-components-3d.
Hi Ali,
I checked out the data file and ran the code. It looks like there's only a single connected component in the data (some kind of wheel or cap?). This library will detect labels separated by at least one voxel (or since you selected 18 connectivity, one voxel or only touching at the corners). Maybe you meant to run your segmentation algorithm first? That would make more sense b/c then different parts separated in space would have the same label and CCL would have something to work with.
Will
from connected-components-3d.
Will,
Thank you for trying this out for me. I would like to mention that I am currently just going by the paper attached here with this message. Again, being new to python and ML, I might have been misunderstanding but I would appreciate if you could look into the "6.3. Multi-feature recognition" part of the paper if you have some time.
Ali
Zhibo.pdf
from connected-components-3d.
6.3. Multi-feature recognition
A typical CAD component usually has multiple machining features.
Often, some of those features are overlapping. But the FeatureNet
was trained to identify component with single feature only. Therefore,
to enhance the utility of the proposed network and to recognize
multiple overlapping features, it was augmented with a segmentation
technique. First, the input CAD component is voxelized using the
binvox library as discussed before.
So far so good.
The disconnected features or disconnected subset of features
are separated from each other in the voxelized model by using
connected component labeling algorithm provided in the
scikit-image package [35] for Python. Next, each disconnected subset
of features is segmented into single individual features using
watershed segmentation algorithm [36].
In the specific case you provided, there are no disconnected features, so the CCL step is trivial. You should apply watershed to either the output of CCL or the binary directly (as they are essentially the same).
Finally, the single segmented features are passed as input into
the trained CNN model for classification.
Makes sense.
from connected-components-3d.
By the way, if you need a distance transform library for the preprocessing step of watershed, I wrote one: https://github.com/seung-lab/euclidean-distance-transform-3d
It also handles multiple labels. 💃
from connected-components-3d.
Thank you for your valuable inputs.
once thing I was wondering and this might be really not a good idea but is there any way to flip the foreground and background label values. I mean is there any way to label the background of each pixel plane and keep the foreground as 0. This might somehow help in the process of labeling the features (hole, slots, etc) as per the paper. Your inputs are much appreciated.
Ali
from connected-components-3d.
Oh sorry, I thought I had written a response to you but I had only done so in my head.
This is easy to accomplish:
img = ~img # for a binary image
img = L1 * (img == 0) + L2 * (img == 1) # for an arbitrary images where L1 and L2 are new labels to assign
Assuming 0 and 1 are background and foreground respectively.
from connected-components-3d.
Will,
I would like to re-iterate, I am a newbie at machine learning and python. Just to confirm, the cc3d output is "extracted image". Should I be adding this piece of the code after that or this needs to be added in one of the source codes?
I once again apologize for my ignorance.
from connected-components-3d.
Hi Ali,
The reason for the extracted_image
code is that cc3d will label all the connected shapes in the array, but often we want to submit only one of the components at a time for further processing (as is the case in the paper you referenced). If you know the label of the component you want to manipulated, you can use: labels_out == label
to turn it into a binary image. I then multiply it as labels_out * (labels_out == segid)
in order to preserve the label name in the binary image, but this is not necessary.
Will
from connected-components-3d.
Will, I am sorry but I still am having an issue understanding this concept. I really apologize for the continuous back and forth and I appreciate your patience towards me. Even after doing X=~X to sort of flip the binary image, the output are just 2 labels. I am pretty sure I am doing something horribly wrong here.
Without wasting much of your valuable time, if you can please post an example from your densely labeled 3D image for a better understanding of the inputs and outputs I will be highly obliged for the same. Hopefully that will reduce my confusion.
Eventually, I will bother you if at all I have more questions which I am being completely honest I will. :)
from connected-components-3d.
Hi Ali,
If you flip the binary image, I'm not sure that it will actually produce additional components as there didn't seem to be any fully enclosed internal holes in the object.
However, if you're interested in seeing a densely labeled image, check out this link.
Check out this youtube video for an explanation of what this algorithm is doing: https://www.youtube.com/watch?v=ticZclUYy88
from connected-components-3d.
William,
In the last 2 weeks, I tried a few things for component labeling. I treated my binary as 2D instead of 3d and used a 2d labeling code and flipped the background, foreground information. I was able to achieve segmentation but its not exactly what I what since now i have segmentation info along 3 separate axis and now merging them together is an issue. Please find attached, the snippet of my code and the files associated with it, What would be really helpful would be if you could please tell me how to treat foreground as background and vice versa in cc3d and I think it will complete the process. Once again I apologize for the inconvenience.
Github.zip
from connected-components-3d.
Hi Ali,
To treat background as foreground write ~img
, but I don't think that necessarily does what you want. The 2D code broke things into multiple components because you were looking at slices of a 3D object. For example if you draw a line through a U
shape (U), you'll see . .
in the 1D projection, which would be two distinct connected components, but the U
is a single connected component in two dimensions.
I meshed the object to get a better look at it. It looks like it has a single connected component. Taking the inverse of this will give you the holes in the wheel, but it may still be a single connected component because the holes touch the surrounding space as well.
from connected-components-3d.
Will, you are absolutely right. Once I inverse the binary model, the out labels are still the foreground and the background. The 'disconnected component labeling' doesn't happen as I want to using cc3d. I dont know how else to approach this issue.
from connected-components-3d.
I think I don't fully understand what you want to happen. Can you explain what parts of the image you'd like to see isolated?
from connected-components-3d.
Will, I am attaching an image of the disconnected component labeling that I achieved with 2D labeling by inversing the foreground and background. I want this in 3D. So instead of the connected voxel labeling I want the labels to be assigned to the disconnected voxels which in my case are holes, in all 3 axes. The labeling will be further taken into segmentation and each label needs to be classified using a trained model that I have.
The image shows the 8th layer of the axis 2 of the binvox file I sent you in the last message.
from connected-components-3d.
What you can do is paint another ID above and below the object. This might be easy to do with a few numpy commands like img[:,:,:5] = 2
or some such. If hard pressed, you can manually paint individual voxels until you get a good result either in numpy or using a painting program like https://www.piskelapp.com/ on individual slices.
Binary thinking is overrated. ;)
from connected-components-3d.
Hi Ali,
Let me know if this fixed things for you. I'll close this issue due to inactivity in a few days. Feel free to reopen if you need to!
Will
from connected-components-3d.
Related Issues (20)
- Applying Dust and largest_k dtype output option HOT 2
- dust sugnature HOT 1
- Massive memory Leak HOT 7
- 1D Array of 4 Elements Incorrect HOT 5
- Cannot find reference 'dust' in 'cc3d.py' HOT 2
- Question on comparing individual lesions between two masks based on the cc3d.statistics output. HOT 1
- Additional metrics support HOT 2
- Does cc3d also work with memmory-mapped numpy arrays and array-like data? HOT 14
- cc3d.statistics["bounding_boxes"] are wrong HOT 1
- largest_k fails for transposed arrays HOT 6
- About the lastest_k function HOT 4
- Statistics output HOT 7
- Question on the output of contacts HOT 9
- Periodic Boundary Conditions HOT 4
- Is the output label of largest_k ordered? HOT 2
- Add Remove Dust Function HOT 2
- cc3d.statistics['bounding_boxes'] is contains floats instead of int as slice positions HOT 2
- voxel_connectivity_graph and contacts can not be applied in 2D label HOT 5
- Build Equivalence Table Two Z Slices at a Time
- cc3d.dust fails HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from connected-components-3d.