Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Python/Filters/GrayscaleNormalizer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Normalize Grayscale Values [Python] #

## Group (Subgroup) ##

Processing(Normalization)

## Description ##

This **Filter** normalizes brightness and contrast values in a 3D grayscale data array. The **Filter** gets the averages each layer in the x, y, or z direction.

## Parameters ##

| Name | Type | Description |
|------|------|------|
| Slice Axis | int | The direction for each layer |
| Create New Array | boolean | If checked, a new array is created with the corrected values. Else, the inputted array is overwritten. |


## Required Geometry ##

Image

## Required Objects ##

| Kind | Default Name | Type | Component Dimensions | Description |
|------|------|------|------|------|
| **Cell Data Array** | AttributeArray Name | Any | (3) | The selected data array to apply normalization |

## Created Objects ##

| Kind | Default Name | Type | Component Dimensions | Description |
|------|------|------|------|------|
| **Cell Data Array** |AttributeArray Name | same as Required Data Array | (3) | Optional array created to store normalized data |


## Example Pipelines ##

List the names of the example pipelines where this filter is used.

## License & Copyright ##

Please see the description file distributed with this plugin.

## DREAM3D Mailing Lists ##

If you need more help with a filter, please consider asking your question on the DREAM3D Users mailing list:
https://groups.google.com/forum/?hl=en#!forum/dream3d-users
5 changes: 5 additions & 0 deletions Python/Filters/TDMStoH5.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

Example(Sub Example)

## Required Conda Packages ##

+ h5py
+ nptdms

## Description ##

This **Filter** converts a series of TDMS files into individual part files, where each part is stored in an HDF5 file. Three offsets can be used for the camera, diode, and laser.
Expand Down
76 changes: 52 additions & 24 deletions Python/Filters/d3d_review_filter_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@


from typing import List, Tuple, Union
from dream3d.Filter import Filter, FilterDelegatePy
from dream3d.simpl import BooleanFilterParameter, DataContainerArray, StringFilterParameter, InputFileFilterParameter, FilterDelegateCpp, FilterParameter, IntFilterParameter, DataArraySelectionFilterParameter, DataArrayPath
from dream3d.simpl import InputPathFilterParameter, FloatFilterParameter

class D3DReviewTestFilter(Filter):
from dream3d.Filter import Filter as SIMPLFilter
from dream3d.Filter import FilterDelegatePy as SIMPLFilterDelegatePy
from dream3d.simpl import *
import dream3d.simpl as simpl


class D3DReviewTestFilter(SIMPLFilter):
def __init__(self) -> None:
self.int_param: int = 5
self.dap_param: DataArrayPath = DataArrayPath('', '', '')
self.dap_param: simpl.DataArrayPath = simpl.DataArrayPath('', '', '')
self.str_param: str = "Something"
self.bool_param:bool = False
self.input_file_param:str = "/No/Path/anywhere.txt"
Expand All @@ -74,6 +77,7 @@ def __init__(self) -> None:

def _set_float_param(self, value: float) -> None:
self.float_param = value

def _get_float_param(self) -> float:
return self.float_param

Expand All @@ -83,10 +87,10 @@ def _set_int(self, value: int) -> None:
def _get_int(self) -> int:
return self.int_param

def _set_dap(self, value: DataArrayPath) -> None:
def _set_dap(self, value: simpl.DataArrayPath) -> None:
self.dap_param = value

def _get_dap(self) -> DataArrayPath:
def _get_dap(self) -> simpl.DataArrayPath:
return self.dap_param

def _get_str(self) -> str:
Expand All @@ -113,7 +117,6 @@ def _get_input_path_param(self) -> str:
def _set_input_path_param(self, value: str) -> None:
self.input_path_param = value


@staticmethod
def name() -> str:
return 'D3DReviewTestFilter'
Expand Down Expand Up @@ -142,34 +145,59 @@ def version() -> str:
def compiled_lib_name() -> str:
return 'DREAM3DReview [Python]'

def setup_parameters(self) -> List[FilterParameter]:
req = DataArraySelectionFilterParameter.RequirementType()

def setup_parameters(self) -> List[simpl.FilterParameter]:

"""
inline const QString Bool("bool");
inline const QString Float("float");
inline const QString Double("double");
inline const QString Int8("int8_t");
inline const QString UInt8("uint8_t");
inline const QString Int16("int16_t");
inline const QString UInt16("uint16_t");
inline const QString Int32("int32_t");
inline const QString UInt32("uint32_t");
inline const QString Int64("int64_t");
inline const QString UInt64("uint64_t");
"""
# Create a DataArraySelectionFilterParameter Requirement Type that only takes the following:
# Image Geometry
# AttributeMatrix must be a CellType
# DataArrayTypes are only float, double, int32_t # See the list from above
# DataArray Component dimensions are 1 or 3, i.e., a scalar or vector of size 3 only
req = simpl.DataArraySelectionFilterParameter.RequirementType()
req.dcGeometryTypes = [simpl.IGeometry.Type.Image]
req.amTypes = [simpl.AttributeMatrix.Type.Cell]
req.daTypes = ["float", "double", "int32_t"]
req.componentDimensions = [VectorSizeT([1]), VectorSizeT([3])]

return [
IntFilterParameter('Integer', 'int_param', self.int_param, FilterParameter.Category.Parameter, self._set_int, self._get_int, -1),
DataArraySelectionFilterParameter('Data Array Path Selection', 'dap_param', self.dap_param, FilterParameter.Category.RequiredArray, self._set_dap, self._get_dap, req, -1),
StringFilterParameter('String', 'str_param', self.str_param, FilterParameter.Category.Parameter, self._set_str, self._get_str, -1),
BooleanFilterParameter('Boolean', 'bool_param', self.bool_param, FilterParameter.Category.Parameter, self._set_bool, self._get_bool, -1),
InputFileFilterParameter('Input File', 'input_file_param', self.input_file_param,
FilterParameter.Category.Parameter, self._set_input_file, self._get_input_file,'*.ang', 'EDAX Ang', -1),
InputPathFilterParameter('Input Directory', 'input_path_param', self.input_path_param,
FilterParameter.Category.Parameter, self._set_input_path_param, self._get_input_path_param, -1)
simpl.IntFilterParameter('Integer', 'int_param', self.int_param, simpl.FilterParameter.Category.Parameter, self._set_int, self._get_int, -1),
simpl.DataArraySelectionFilterParameter('Data Array Path Selection', 'dap_param', self.dap_param, simpl.FilterParameter.Category.RequiredArray, self._set_dap, self._get_dap, req, -1),
simpl.StringFilterParameter('String', 'str_param', self.str_param, simpl.FilterParameter.Category.Parameter, self._set_str, self._get_str, -1),
simpl.BooleanFilterParameter('Boolean', 'bool_param', self.bool_param, simpl.FilterParameter.Category.Parameter, self._set_bool, self._get_bool, -1),
simpl.InputFileFilterParameter('Input File', 'input_file_param', self.input_file_param,
simpl.FilterParameter.Category.Parameter, self._set_input_file, self._get_input_file,'*.ang', 'EDAX Ang', -1),
simpl.InputPathFilterParameter('Input Directory', 'input_path_param', self.input_path_param,
simpl.FilterParameter.Category.Parameter, self._set_input_path_param, self._get_input_path_param, -1)
]

def data_check(self, dca: DataContainerArray, delegate: Union[FilterDelegateCpp, FilterDelegatePy] = FilterDelegatePy()) -> Tuple[int, str]:
def data_check(self, dca: simpl.DataContainerArray, delegate: Union[simpl.FilterDelegateCpp, SIMPLFilterDelegatePy] = SIMPLFilterDelegatePy()) -> Tuple[int, str]:
am = dca.getAttributeMatrix(self.dap_param)

if am is None:
return (-1, 'AttributeMatrix is None')
return -1, 'AttributeMatrix is None'

da = am.getAttributeArray(self.dap_param)
if da is None:
return (-2, 'DataArray is None')
return -2, 'DataArray is None'

delegate.notifyStatusMessage('data_check finished!')

return (0, 'Success')
return 0, 'Success'

def _execute_impl(self, dca: DataContainerArray, delegate: Union[FilterDelegateCpp, FilterDelegatePy] = FilterDelegatePy()) -> Tuple[int, str]:
def _execute_impl(self, dca: simpl.DataContainerArray, delegate: Union[simpl.FilterDelegateCpp, SIMPLFilterDelegatePy] = SIMPLFilterDelegatePy()) -> Tuple[int, str]:
delegate.notifyStatusMessage(f'int_param = {self.int_param}')

da = dca.getAttributeMatrix(self.dap_param).getAttributeArray(self.dap_param)
Expand All @@ -180,6 +208,6 @@ def _execute_impl(self, dca: DataContainerArray, delegate: Union[FilterDelegateC
delegate.notifyStatusMessage(f'after = {data}')

delegate.notifyStatusMessage('execute finished!')
return (0, 'Success')
return 0, 'Success'

filters = [D3DReviewTestFilter]
Loading