cleanX.image_work.steps module¶
- cleanX.image_work.steps.get_known_steps()¶
- class cleanX.image_work.steps.RegisteredStep(name, bases, clsdict)¶
Bases:
type
- __init__(name, bases, clsdict)¶
- mro()¶
Return a type’s method resolution order.
- class cleanX.image_work.steps.Step(cache_dir=None)¶
Bases:
object
This class has default implementations for methods all steps are expected to implement.
Use this as the base class if you intend to add custom steps.
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- begin_transaction()¶
- commit_transaction()¶
- __reduce__()¶
Helper for pickle.
- to_json()¶
- classmethod from_cmd_args(cmd_args)¶
- class cleanX.image_work.steps.Aggregate(cache_dir=None)¶
Bases:
Step
This class has default implementations for methods all aggregate steps are expected to implement. These types of steps combine and accumalte data on the individual images processed in a step.
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- begin_transaction()¶
- commit_transaction()¶
- pre()¶
- post(accumulator)¶
- agg(acc_data, acc_name, image_data, image_name)¶
- aggregate(accum, new)¶
- __reduce__()¶
Helper for pickle.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.Mean(cache_dir=None)¶
Bases:
Aggregate
This class builds an averaged (by mean) image.
- agg(acc_data, acc_name, image_data, image_name)¶
- post(acc)¶
- __reduce__()¶
Helper for pickle.
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- aggregate(accum, new)¶
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- pre()¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.GroupHistoHtWt(histo_dir, cache_dir=None)¶
Bases:
Aggregate
This class builds a histogram of individual image heights and widths.
- __init__(histo_dir, cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- agg(acc_data, acc_name, image_data, image_name)¶
- post(acc)¶
- __reduce__()¶
Helper for pickle.
- aggregate(accum, new)¶
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- pre()¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.GroupHistoPorportion(histo_dir, cache_dir=None)¶
Bases:
Aggregate
This class makes a histogram of all the image’s proportions.
- __init__(histo_dir, cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- agg(acc_data, acc_name, image_data, image_name)¶
- post(acc)¶
- __reduce__()¶
Helper for pickle.
- aggregate(accum, new)¶
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- pre()¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.Acquire(cache_dir=None)¶
Bases:
Step
This class reads in images (to an array) from a path
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- __reduce__()¶
Helper for pickle.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.Save(target, extension='jpg', cache_dir=None)¶
Bases:
Step
This class writes the images somewhere
- __init__(target, extension='jpg', cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- __reduce__()¶
Helper for pickle.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- class cleanX.image_work.steps.FourierTransf(cache_dir=None)¶
Bases:
Step
This class makes a fourier transformation of the image
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.ContourImage(cache_dir=None)¶
Bases:
Step
This class makes a transformation into a many line contour based image from the original image
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.ProjectionHorizoVert(cache_dir=None)¶
Bases:
Step
This class makes a transformation into a projection of the image. The projections of horizontal and vertical are superimposed. These one dimensional projection images can be used for image registration algorithms, quality control or other purposes
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.BlackEdgeCrop(cache_dir=None)¶
Bases:
Step
This class crops image arrays of black frames
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.WhiteEdgeCrop(cache_dir=None)¶
Bases:
Step
This class crops image arrays of white frames
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.Sharpie(ksize=(2, 2), cache_dir=None)¶
Bases:
Step
This class takes the image and applies a variant of the subtle_sharpie function, but with control over the degree. In present version, it is recommended to run on copies. In future versions can be run after a Tee step. For a subtle sharpening a ksize of (2,2) is recommended, and a run of normalization afterwards is highly recommended (or you may get vals over 255 for whites)
- __init__(ksize=(2, 2), cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.BlurEdges(ksize=(600, 600), cache_dir=None)¶
Bases:
Step
This class takes the image and applies a variant of the blur out edges function, which does what it sounds like (returns an image with edges blurred out called edge_image). For a good effect a ksize of (600,600) is recommended. In present version,it is recommended to run on copies.In future versions can be run after a Tee step.
- __init__(ksize=(600, 600), cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.CleanRotate(angle=2, cache_dir=None)¶
Bases:
Step
This class takes the image and applies a rotation function, with control over the degree. It crops off black added (makes smaller borders, but will not crop existing borders) In present version, it is recommended to run on copies. In future versions can be run after a Tee step.
- __init__(angle=2, cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.Normalize(cache_dir=None)¶
Bases:
Step
This class makes a simple normalizing to get values 0 to 255.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.HistogramNormalize(tail_cut_percent=5, cache_dir=None)¶
Bases:
Step
This class allows normalization by throwing off extreme values on image histogram.
- __init__(tail_cut_percent=5, cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.InvertImages(cache_dir=None)¶
Bases:
Step
This class inverts and image black to white and vice vera
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.OtsuBinarize(ksize=5, cache_dir=None)¶
Bases:
Step
This class makes binarized images with values of only 0 to 255, based on an Otsu segmentation with more or less blurring. ksize parameter should be between 1 and 99, and odd
- __init__(ksize=5, cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.OtsuLines(ksize=5, cache_dir=None)¶
Bases:
Step
This class makes an outline around a segemnted image segmented based on the an Otsu segmentation with more or less blurring. ksize parameter should be between 1 and 99, and odd
- __init__(ksize=5, cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.
- class cleanX.image_work.steps.Projection(cache_dir=None)¶
Bases:
Step
This class makes two one dimensional projections on the same graph, one for horizontal, and one for vertical. Projections can be used in many processes including registration, and analysis.
- apply(image_data, image_name)¶
This is the method that will be called to do the actual image transformation. This function must not raise exceptions, as it is used in the
multiprocessing
context.- Parameters:
image_data (Unless this class overrides the defaults, this will be
ndarray
.) – Will be the data obtained when callingread()
method of this class.- Returns:
This method should return two values. First is the processed image data. This should be suitable for the
write()
method of this class to write. Second is the error, if procesing wasn’t possible. Only one element of the tuple should benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- __init__(cache_dir=None)¶
If you extend this class, you need to call its
__init__
.
- __reduce__()¶
Helper for pickle.
- begin_transaction()¶
- commit_transaction()¶
- classmethod from_cmd_args(cmd_args)¶
- read(path)¶
Read the image saved in the previous step. This function must not raise exceptions as it is used in
multiprocessing
context.- Parameters:
path – The path to the image to read. Unless the
write()
method of the previous step was modified to do it differently, the format of the data in the file is the serialized NumPy array- Returns:
This method should return two values. First is the image data read from
path
. It should be in the format suitable forapply()
. Second is theException
if the read was not successful. Only one element in the tuple may benot None
.- Return type:
Tuple[numpy.ndarray, Exception]
- to_json()¶
- write(image_data, path)¶
This method should write the image data to make it available for the next step. Default implementation use NumPy’s persistence format. This method is used in
multiprocessing
context, therefore it must not raise exceptions.