Skip to content
Snippets Groups Projects
Commit f79b1e18 authored by Eric Wait's avatar Eric Wait
Browse files

Attempting to fix the hull vert offset when making polygons

parent be30a81e
Branches
No related tags found
No related merge requests found
......@@ -25,31 +25,39 @@ if (~exist('quiet','var') || isempty(quiet))
quiet = false;
end
reductions = [1,1,1];
polygon = D3d.Polygon.MakeEmptyStruct();
% padd the subimage to get some room to blur
PADDING = ceil(5*1./reductions);
maxExtent_rc = Utils.SwapXY_RC(max(pixelList_xy,[],1)) + PADDING;
indList = Utils.CoordToInd(maxExtent_rc,Utils.SwapXY_RC(pixelList_xy));
[im,startCoords_rcz] = ImUtils.ROI.MakeSubImBW(maxExtent_rc,indList,PADDING);
startCoords_xy = Utils.SwapXY_RC(startCoords_rcz);
startCoords_rcz = Utils.SwapXY_RC(min(pixelList_xy,[],1));
endCoords_rcz = Utils.SwapXY_RC(max(pixelList_xy,[],1));
startPadded = startCoords_rcz-PADDING;
endPadded = endCoords_rcz+PADDING;
roiIm = false(endPadded-startPadded+1);
paddedPixelList_rcz = Utils.SwapXY_RC(pixelList_xy)-startPadded+1;
indList = Utils.CoordToInd(size(roiIm),paddedPixelList_rcz);
roiIm(indList) = true;
cc.Connectivity = 26;
cc.ImageSize = size(im);
cc.ImageSize = size(roiIm);
cc.NumObjects = 1;
cc.PixelIdxList = {find(im)};
cc.PixelIdxList = {indList};
rp = regionprops(cc,'Centroid');
imR = ImProc.Resize(im2uint8(im),reductions,[],'mean');
imR = ImProc.Resize(im2uint8(roiIm),reductions,[],'mean');
endCoords_rcz = startCoords_rcz + floor((maxExtent_rc - startCoords_rcz).*reductions)./reductions;
R = linspace(startCoords_rcz(1),endCoords_rcz(1),size(imR,1));
C = linspace(startCoords_rcz(2),endCoords_rcz(2),size(imR,2));
Z = linspace(startCoords_rcz(3),endCoords_rcz(3),size(imR,3));
R = linspace(startPadded(1),endPadded(1),size(imR,1));
C = linspace(startPadded(2),endPadded(2),size(imR,2));
Z = linspace(startPadded(3),endPadded(3),size(imR,3));
[x,y,z] = meshgrid(C,R,Z);
[faces, v_xy] = isosurface(x,y,z,imR,160);
[faces, v_xy] = isosurface(x,y,z,imR,1);
if (isempty(v_xy))
return
......@@ -58,7 +66,7 @@ end
% center the vert in the middle of the voxel
verts_xy = v_xy + 0.5;
com = rp.Centroid + startCoords_xy -1;
com = rp.Centroid + startPadded -1;
if (any(faces(:)==0))
error('there is a zero index in the faces structure!');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment