Commit f72b0ca6 authored by josh's avatar josh
Browse files

cleaning up readme

parent 6525fc9a
......@@ -179,37 +179,39 @@ def importAndProcess( imgPath: str, dbPath: str, newImgName: str ):
os.mkdir( imgSlicedSizePath )
os.mkdir( imgMSSizePath )
# Step 4: Slice
sliceResults = sliceImage( imgArr, ( size, size ) )
# Step 5: Save slices
for res in sliceResults["slicedImages"]:
i = res[0]
j = res[1]
slicedImg = res[2]
finalFileName = "{}-{}-{}".format( newImgName, i, j )
sliceSizePath = imgSlicedSizePath.joinpath( "{}.{}".format( finalFileName, fileExt ) )
print( "SAVING IMAGE:", sliceSizePath )
cv2.imwrite( str( sliceSizePath ), slicedImg )
# Step 6: Mean Shift
( segmentedImage, labelsImage, numberRegions ) = meanShiftSegmentation( slicedImg )
# Step 7: Save MS results
segColorPath = imgMSSizePath.joinpath( "{}-color-seg.{}".format( finalFileName, fileExt ) )
labelImgPath = imgMSSizePath.joinpath( "{}-labels-image.{}".format( finalFileName, fileExt ) )
print( "SAVING IMAGE:", segColorPath )
print( "SAVING IMAGE:", labelImgPath )
# scale labelsImage to [0,255]
labelsImage = labelsImage.astype( float )
labelsImage /= labelsImage.max()
labelsImage *= 255
# save results to image files
cv2.imwrite( str( segColorPath ), segmentedImage )
cv2.imwrite( str( labelImgPath ), labelsImage )
if imgArr.shape[0] >= size and imgArr.shape[1] >= size:
# Step 4: Slice
sliceResults = sliceImage( imgArr, ( size, size ) )
# Step 5: Save slices
for res in sliceResults["slicedImages"]:
i = res[0]
j = res[1]
slicedImg = res[2]
finalFileName = "{}-{}-{}".format( newImgName, i, j )
sliceSizePath = imgSlicedSizePath.joinpath( "{}.{}".format( finalFileName, fileExt ) )
print( "SAVING IMAGE:", sliceSizePath )
cv2.imwrite( str( sliceSizePath ), slicedImg )
# Step 6: Mean Shift
( segmentedImage, labelsImage, numberRegions ) = meanShiftSegmentation( slicedImg )
# Step 7: Save MS results
segColorPath = imgMSSizePath.joinpath( "{}-color-seg.{}".format( finalFileName, fileExt ) )
labelImgPath = imgMSSizePath.joinpath( "{}-labels-image.{}".format( finalFileName, fileExt ) )
print( "SAVING IMAGE:", segColorPath )
print( "SAVING IMAGE:", labelImgPath )
# scale labelsImage to [0,255]
labelsImage = labelsImage.astype( float )
labelsImage /= labelsImage.max()
labelsImage *= 255
# save results to image files
cv2.imwrite( str( segColorPath ), segmentedImage )
cv2.imwrite( str( labelImgPath ), labelsImage )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment