Closed KnewHow closed 1 year ago
Hi @KnewHow,
Thanks for you enquiry. I don't have an environment set up to test it but I suspect the problem occurs on lines 10-16 of your labelReduction
function where you compute the neighbouring connections - nzm1yx, nzym1x, nzyxm1, nzym1xm1, nzm1yxm1, nzm1ym1x
.
These should represent the connections between neighbouring voxels and in the original implementation it tests whether the image value pzyx
is equal to the image value of various neighbours. Your code seems to compare the value of the image pzyx
with the value of the neighbouring labels instead.
What this means is that you'll only be getting labels from the init_label
step where the kernel looks at the neighbours and initialises the label with the best guess from the neighbours.
As another note, this implementation of component labelling will compute a label for every voxel in your dataset, it doesn't discriminate between background and foreground image data as I originally wrote it for some statistical mechanics. If you want it to ignore the background voxels (data points with a value of 0) then you would need to add a condition to the init_label
and label_reduction
to ignore voxels with a value of 0.
Regards
Thank you very much, you solve my problem. Best wish! My code has some problem in
const bool nzm1yx = (iz > 0) ? (pzyx == Labels[(iz - 1) * PY + iy * PX + ix]) : false;
const bool nzym1x = (iy > 0) ? (pzyx == Labels[iz * PY + (iy - 1) * PX + ix]) : false;
const bool nzyxm1 = (ix > 0) ? (pzyx == Labels[iz * PY + iy * PX + ix - 1]) : false;
const bool nzym1xm1 = ((iy > 0) && (ix > 0)) ? (pzyx == Labels[iz * PY + (iy - 1) * PX + ix - 1]) : false;
const bool nzm1yxm1 = ((iz > 0) && (ix > 0)) ? (pzyx == Labels[(iz - 1) * PY + iy * PX + ix - 1]) : false;
const bool nzm1ym1x = ((iz > 0) && (iy > 0)) ? (pzyx == Labels[(iz - 1) * PY + (iy - 1) * PX + ix]) : false;
It should be
const bool nzm1yx = (iz > 0) ? (pzyx == Volume[(iz - 1) * PY + iy * PX + ix]) : false;
const bool nzym1x = (iy > 0) ? (pzyx == Volume[iz * PY + (iy - 1) * PX + ix]) : false;
const bool nzyxm1 = (ix > 0) ? (pzyx == Volume[iz * PY + iy * PX + ix - 1]) : false;
const bool nzym1xm1 = ((iy > 0) && (ix > 0)) ? (pzyx == Volume[iz * PY + (iy - 1) * PX + ix - 1]) : false;
const bool nzm1yxm1 = ((iz > 0) && (ix > 0)) ? (pzyx == Volume[(iz - 1) * PY + iy * PX + ix - 1]) : false;
const bool nzm1ym1x = ((iz > 0) && (iy > 0)) ? (pzyx == Volume[(iz - 1) * PY + (iy - 1) * PX + ix]) : false;
I view your algorithms in
playne_equivalence_direct_3D_clamp.cu
and I implement with dx11 computer shader with same codeThen I test it, I have a
128x128x128
cube volume, and I init it with a sphere in center, I think the connected-component is sphere volume, So I init the cube volume with 1 in shpere area, otherwise is zero.Then I run the algorithms, and get the Labels, then I print the lable with following code:
The I print it each 32 with a newline, you can download the file from this link: Lables data Then I use volume render to render it with above init: if the Labes value in current index is greater than zero, I give the voxel with two bytes in [1,1], otherwise I give the voxel with two bytes is[0,0], Then I use accumulated volume render to render it, I find some question in it. You can get the render image from this: https://drive.google.com/file/d/1KY5mQ5JcsRzA4bPxCRNh8tSPeuYPa2rG/view?usp=sharing Why some connected-component outer of the sphere, I think the connected-component should in the inner of the shpere. Is there some bug in my code? Would you help me to solve this problem?