use of org.dcm4che3.img.op.MaskArea in project karnak by OsiriX-Foundation.
the class Profile method applyCleanPixelData.
public void applyCleanPixelData(Attributes dcmCopy, AttributeEditorContext context, ProfileEntity profileEntity) {
Object pix = dcmCopy.getValue(Tag.PixelData);
if ((pix instanceof BulkData || pix instanceof Fragments) && !profileEntity.getMaskEntities().isEmpty() && profiles.stream().anyMatch(p -> p instanceof CleanPixelData)) {
String sopClassUID = dcmCopy.getString(Tag.SOPClassUID);
if (!StringUtil.hasText(sopClassUID)) {
throw new IllegalStateException("DICOM Object does not contain sopClassUID");
}
String scuPattern = sopClassUID + ".";
MaskArea mask = getMask(dcmCopy.getString(Tag.StationName));
// BurnedInAnnotation
if (isCleanPixelAllowedDependingImageType(dcmCopy, sopClassUID, scuPattern) && evaluateConditionCleanPixelData(dcmCopy)) {
context.setMaskArea(mask);
if (mask == null) {
throw new IllegalStateException("Clean pixel is not applied: mask not defined in station name");
}
} else {
context.setMaskArea(null);
}
}
}
use of org.dcm4che3.img.op.MaskArea in project karnak by OsiriX-Foundation.
the class Profile method createProfilesList.
public List<ProfileItem> createProfilesList(final ProfileEntity profileEntity) {
if (profileEntity != null) {
List<ProfileItem> profileItems = getProfileItems(profileEntity);
profileEntity.getMaskEntities().forEach(m -> {
Color color = null;
if (StringUtil.hasText(m.getColor())) {
color = ActionTags.hexadecimal2Color(m.getColor());
}
List<Shape> shapeList = m.getRectangles().stream().map(Shape.class::cast).collect(Collectors.toList());
addMask(m.getStationName(), new MaskArea(shapeList, color));
});
return profileItems;
}
return Collections.emptyList();
}
use of org.dcm4che3.img.op.MaskArea in project karnak by OsiriX-Foundation.
the class ForwardService method transformImage.
private static Editable<PlanarImage> transformImage(Attributes attributes, AttributeEditorContext context) {
MaskArea m = context.getMaskArea();
boolean defacing = LangUtil.getEmptytoFalse(context.getProperties().getProperty(Defacer.APPLY_DEFACING));
if (m != null || defacing) {
return img -> {
PlanarImage image = img;
if (defacing) {
image = Defacer.apply(attributes, image);
}
if (m != null) {
image = MaskArea.drawShape(image.toMat(), m);
}
return image;
};
}
return null;
}
Aggregations