PixelPartitioner
Short Description
The PixelPartitioner
function applies multi-class OTSU thresholding to a set of images
to partition pixels based on intensity. It iteratively increases the number of classes for
images with a high percentage of pixels exceeding a specified threshold, accumulating
results in a DataFrame. The final results are saved in a CSV file within the specified output folder.
Function¶
PixelPartitioner(imagePaths, outputFolder, num_classes=2, percentPositiveThreshold=5, verbose=True)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
imagePaths |
list of str
|
A list of paths to images that will undergo pixel partitioning. |
required |
outputFolder |
str
|
The directory where the output results, including a master DataFrame as a CSV file, will be saved. The function will create a 'results' subfolder in this directory for the CSV file. |
required |
num_classes |
int
|
The initial number of classes to use for OTSU thresholding. Default is 2. |
2
|
percentPositiveThreshold |
int or float
|
The percentage threshold used to determine if an image has a greater percentage of pixels in the highest class than specified. Images exceeding this threshold will be re-processed in subsequent iterations with an increased number of classes. Default is 5. |
5
|
verbose |
bool
|
If True, the function will print verbose messages about its progress. Default is True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
A DataFrame containing the cumulative results of the pixel partitioning process, with columns representing the results of different num_classes iterations. |
Example
imagePaths = ['/path/to/images/img1.tif', '/path/to/images/img2.tif']
outputFolder = '/path/to/output'
num_classes = 2
percentPositiveThreshold = 5
# Execute pixel partitioning
results_df = pp.PixelPartitioner(imagePaths=imagePaths,
outputFolder=outputFolder,
num_classes=num_classes,
percentPositiveThreshold=percentPositiveThreshold)
Source code in pixelpartitioner/PixelPartitioner.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|