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

Merge branch 'master' into 'master'

Split Hull Bug Fix

There was a bug in splitting hulls where the new hulls did not retain their pixel lists.  This has now been fixed.

Please allow this fix to be merged.
parents b8325d3c 593a8adf
No related branches found
No related tags found
No related merge requests found
......@@ -282,8 +282,8 @@ void createStaticVolumeShaderText(std::string strChans)
shaderText += "\n";
shaderText += "struct PixelOutputType\n";
shaderText += "{\n";
shaderText += " float4 color : SV_TARGET;\n";
shaderText += " float depth : SV_DEPTH;\n";
shaderText += "\tfloat4 color : SV_TARGET;\n";
shaderText += "\tfloat depth : SV_DEPTH;\n";
shaderText += "};\n";
shaderText += "\n";
shaderText += "Texture3D g_txDiffuse[" + strChans + "] : register( t0 );\n";
......@@ -303,14 +303,26 @@ void createStaticVolumeShaderText(std::string strChans)
shaderText += "\tfloat alpha = 0.0f;\n";
shaderText += "\n";
shaderText += "\tfloat4 mainLightDir = float4(-0.5774,-0.5774,0.5774,0);\n";
shaderText += "\tfloat unlitComposite = 0.0f;\n";
shaderText += "\tfloat3 unlitComposite = float3(0.0f,0.0f,0.0f);\n";
shaderText += "\tfloat3 alphaComposite = float3(0.0f,0.0f,0.0f);\n";
shaderText += "\n";
shaderText += "\tint numAlpha = 0;\n";
shaderText += "\tfloat3 grad;\n";
shaderText += "\n";
shaderText += "float maxIntensity = 0;\n";
shaderText += "\n";
shaderText += "\t[unroll(" + strChans + ")] for (int i=0; i<" + strChans + "; ++i)\n";
shaderText += "\t{\n";
shaderText += "\t\tfloat intensity = g_txDiffuse[i].Sample( g_samLinear[i], input.TextureUV );\n";
shaderText += "\t\tintensity = clamp(intensity,ranges[i][0],ranges[i][1]);\n";
shaderText += "\t\tintensity = transferFunctions[i][0]*intensity*intensity+transferFunctions[i][1]*intensity+transferFunctions[i][2];\n";
shaderText += "\t\tif (intensity < 0.2f || channelColor[i].a < 0.01f)\n";
shaderText += "\t\t{\n";
shaderText += "\t\t\tintensity = 0;\n";
shaderText += "\t\t}\n";
//shaderText += "\t\tmaxIntensity = max(intensity*channelColor[i].a,maxIntensity);\n";
shaderText += "\t\tmaxIntensity = max(intensity,maxIntensity);\n";
shaderText += "\n";
shaderText += "\t\tfloat lightMod = 1.0f;\n";
shaderText += "\t\tif(lightOn.x>0)\n";
shaderText += "\t\t{\n";
......@@ -321,24 +333,29 @@ void createStaticVolumeShaderText(std::string strChans)
shaderText += "\t\t\tgrad.z = g_txDiffuse[i].Sample(g_samLinear[i], input.TextureUV+gradientSampleDirection[2]) - \n";
shaderText += "\t\t\t\tg_txDiffuse[i].Sample(g_samLinear[i], input.TextureUV-gradientSampleDirection[2]);\n";
shaderText += "\t\t\tgrad = normalize(grad);\n";
shaderText += "\t\t\tlightMod = saturate(dot(grad,mainLightDir)*2.0)*0.7 + 0.3;\n";
shaderText += "\t\t\tlightMod = saturate(dot(grad,mainLightDir)*2.0)*0.65 + 0.35;\n";
shaderText += "\t\t}\n";
shaderText += "\t\tif (channelColor[i].a>0)\n";
shaderText += "\t\t\t++numAlpha;\n";
shaderText += "\n";
shaderText += "\t\talpha += channelColor[i].a;\n";
shaderText += "\t\toutput.color.rgb += (lightMod*intensity*channelColor[i].rgb*channelColor[i].a);\n";
shaderText += "\t\tunlitComposite += intensity*channelColor[i].a;\n";
shaderText += "\t\toutput.color.rgb += (lightMod*intensity*channelColor[i].rgb);\n";
shaderText += "\t\tunlitComposite += intensity*channelColor[i].rgb;\n";
shaderText += "\t\talphaComposite += intensity*channelColor[i].rgb*channelColor[i].a;\n";
shaderText += "\t}\n";
shaderText += "\tif (alpha!=0)\n";
shaderText += "\n";
shaderText += "\tfloat maxComponent = max(max(unlitComposite.r,unlitComposite.g),unlitComposite.b);\n";
shaderText += "\tfloat maxAplha = max(max(alphaComposite.r,alphaComposite.g),alphaComposite.b);\n";
shaderText += "\tif (maxComponent!=0)\n";
shaderText += "\t{\n";
shaderText += "\t\toutput.color.rgb /= maxComponent;\n";
shaderText += "\t\toutput.color.rgb *= maxIntensity;\n";
shaderText += "\t}\n";
shaderText += "\tif (maxAplha!=0)\n";
shaderText += "\t{\n";
shaderText += "\t\toutput.color.rgb /= alpha;\n";
shaderText += "\t\toutput.color.rgb = saturate(output.color.rgb*numAlpha*0.5f);\n";
shaderText += "\t\tunlitComposite /= alpha;\n";
shaderText += "\t\toutput.color.a = alpha / numAlpha;\n";
shaderText += "\t\toutput.color.a = maxAplha;\n";
shaderText += "\t}else{\n";
shaderText += "\t\toutput.color.a = 0;\n";
shaderText += "\t}\n";
shaderText += "\toutput.color.a *= saturate(unlitComposite);\n";
shaderText += "\toutput.color.a = output.color.a*step(0.15,output.color.a);\n";
shaderText += "\n";
shaderText += "\n";
shaderText += "\tif(lightOn.y>0)\n";
shaderText += "\t{\n";
shaderText += "\t\tfloat distMult = (input.Dpth.z<=0) ? (1) : (1-input.Dpth.z);\n";
......
......@@ -26,7 +26,7 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ newHulls ] = CreateHulls(bwIm, orgIm, minCellDia, frame, minXY, minZ)
function [ newHulls ] = CreateHulls(bwIm, orgIm, minCellDia, frame, minXY, minZ, labeledIm)
global imageData
newHulls = [];
......@@ -37,6 +37,9 @@ end
if ~exist('minZ','var')
minZ = 0;
end
if ~exist('labeledIm','var')
labeledIm = 0;
end
[newHulls,~,~] = GetEmptyStructs();
imageDims = [imageData.XDimension, imageData.YDimension, imageData.ZDimension];
......@@ -45,7 +48,12 @@ scaleFactor = imageDims ./ max(imageDims) .* physDims/physDims(1);
imDiv = imageDims /2;
minCellVol = (4*pi*(minCellDia/2)^3)/3;
stts = regionprops(bwIm,orgIm,'BoundingBox','PixelList','WeightedCentroid');
if (labeledIm==0)
cc = bwconncomp(bwIm);
else
cc = bwIm;
end
stts = regionprops(cc,orgIm,'BoundingBox','PixelList','WeightedCentroid');
if isempty(stts)
return
end
......
......@@ -35,7 +35,7 @@ for i=1:k
im(idx) = i;
end
newHulls = CreateHulls(im,orgImage(:,:,:,hullChan,Hulls(hull).frame),1,Hulls(hull).frame);
newHulls = CreateHulls(im,orgImage(:,:,:,hullChan,Hulls(hull).frame),1,Hulls(hull).frame,0,0,1);
oldHull = Hulls(hull);
Hulls(hull) = newHulls(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment