Skip to content

Commit

Permalink
Use DicomUtils instead of DicomMediaUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
nroduit committed Dec 21, 2023
1 parent a54e230 commit 64c4603
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 448 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.weasis.dicom.codec.display.ShutterOp;
import org.weasis.dicom.codec.display.WindowAndPresetsOp;
import org.weasis.dicom.codec.geometry.GeometryOfSlice;
import org.weasis.dicom.codec.utils.DicomMediaUtils;
import org.weasis.dicom.codec.utils.Ultrasound;
import org.weasis.dicom.param.AttributeEditorContext;
import org.weasis.opencv.data.ImageCV;
Expand Down Expand Up @@ -145,9 +144,9 @@ private void initPixelValueUnit(String modality) {
Ultrasound.getUniqueSpatialRegion(getMediaReader().getDicomObject());
if (spatialCalibration != null) {
Double calibX =
DicomMediaUtils.getDoubleFromDicomElement(spatialCalibration, Tag.PhysicalDeltaX, null);
DicomUtils.getDoubleFromDicomElement(spatialCalibration, Tag.PhysicalDeltaX, null);
Double calibY =
DicomMediaUtils.getDoubleFromDicomElement(spatialCalibration, Tag.PhysicalDeltaY, null);
DicomUtils.getDoubleFromDicomElement(spatialCalibration, Tag.PhysicalDeltaY, null);
if (calibX != null && calibY != null) {
calibX = Math.abs(calibX);
calibY = Math.abs(calibY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.dcm4che3.img.data.PrDicomObject;
import org.dcm4che3.img.stream.DicomFileInputStream;
import org.dcm4che3.img.stream.ImageDescriptor;
import org.dcm4che3.img.util.DicomUtils;
import org.dcm4che3.io.DicomOutputStream;
import org.opencv.core.Core;
import org.opencv.core.CvType;
Expand Down Expand Up @@ -479,7 +480,7 @@ private void writeInstanceTags(DicomMetaData md) {
setTag(TagW.PatientPseudoUID, patientComparator.buildPatientPseudoUID());

Integer instNb =
DicomMediaUtils.getIntegerFromDicomElement(
DicomUtils.getIntegerFromDicomElement(
header, Tag.InstanceNumber, instanceID.incrementAndGet());
setTag(TagD.get(Tag.InstanceNumber), instNb);
setTag(
Expand Down Expand Up @@ -563,8 +564,7 @@ private void writeImageValues(DicomMetaData md) {
TagD.get(Tag.Units).readValue(header, this);
TagD.get(Tag.NumberOfFrames).readValue(header, this);

int samplesPerPixel =
DicomMediaUtils.getIntegerFromDicomElement(header, Tag.SamplesPerPixel, 1);
int samplesPerPixel = DicomUtils.getIntegerFromDicomElement(header, Tag.SamplesPerPixel, 1);
setTag(TagD.get(Tag.SamplesPerPixel), samplesPerPixel);
String photometricInterpretation =
header.getString(Tag.PhotometricInterpretation, "MONOCHROME2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.dcm4che3.data.Tag;
import org.dcm4che3.data.VR;
import org.dcm4che3.img.util.DateTimeUtils;
import org.dcm4che3.img.util.DicomUtils;
import org.dcm4che3.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -291,7 +292,7 @@ private Object readValue(Attributes dataset) {
if (isStringFamilyType()) {
value =
vmMax > 1
? DicomMediaUtils.getStringArrayFromDicomElement(
? DicomUtils.getStringArrayFromDicomElement(
dataset, id, privateCreatorID, (String[]) defaultValue)
: dataset.getString(privateCreatorID, id, (String) defaultValue);
} else if (TagType.DICOM_DATE.equals(type)
Expand All @@ -306,23 +307,23 @@ private Object readValue(Attributes dataset) {
} else if (TagType.INTEGER.equals(type)) {
value =
vmMax > 1
? DicomMediaUtils.getIntArrayFromDicomElement(
? DicomUtils.getIntArrayFromDicomElement(
dataset, id, privateCreatorID, (int[]) defaultValue)
: DicomMediaUtils.getIntegerFromDicomElement(
: DicomUtils.getIntegerFromDicomElement(
dataset, id, privateCreatorID, (Integer) defaultValue);
} else if (TagType.FLOAT.equals(type)) {
value =
vmMax > 1
? DicomMediaUtils.getFloatArrayFromDicomElement(
? DicomUtils.getFloatArrayFromDicomElement(
dataset, id, privateCreatorID, (float[]) defaultValue)
: DicomMediaUtils.getFloatFromDicomElement(
: DicomUtils.getFloatFromDicomElement(
dataset, id, privateCreatorID, (Float) defaultValue);
} else if (TagType.DOUBLE.equals(type)) {
value =
vmMax > 1
? DicomMediaUtils.getDoubleArrayFromDicomElement(
? DicomUtils.getDoubleArrayFromDicomElement(
dataset, id, privateCreatorID, (double[]) defaultValue)
: DicomMediaUtils.getDoubleFromDicomElement(
: DicomUtils.getDoubleFromDicomElement(
dataset, id, privateCreatorID, (Double) defaultValue);
} else if (TagType.DICOM_SEQUENCE.equals(type)) {
value = dataset.getSequence(privateCreatorID, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.dcm4che3.data.Tag;
import org.dcm4che3.img.data.OverlayData;
import org.dcm4che3.img.data.PrDicomObject;
import org.dcm4che3.img.util.DicomUtils;
import org.weasis.core.api.gui.util.ActionW;
import org.weasis.core.api.image.AbstractOp;
import org.weasis.core.api.image.ImageOpEvent;
Expand All @@ -29,7 +30,6 @@
import org.weasis.core.util.LangUtil;
import org.weasis.dicom.codec.PRSpecialElement;
import org.weasis.dicom.codec.TagD;
import org.weasis.dicom.codec.utils.DicomMediaUtils;
import org.weasis.opencv.data.ImageCV;
import org.weasis.opencv.data.PlanarImage;
import org.weasis.opencv.op.ImageProcessor;
Expand Down Expand Up @@ -128,7 +128,7 @@ public void process() throws Exception {
if (height != null && width != null) {
Attributes attributes = pr.getDicomObject();
Integer shutterOverlayGroup =
DicomMediaUtils.getIntegerFromDicomElement(attributes, Tag.ShutterOverlayGroup, null);
DicomUtils.getIntegerFromDicomElement(attributes, Tag.ShutterOverlayGroup, null);
if (shutterOverlayGroup != null) {
PlanarImage overlayImg = OverlayData.getOverlayImage(result, overlays, frame);
imgOverlay =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.dcm4che3.data.Sequence;
import org.dcm4che3.data.Tag;
import org.dcm4che3.data.VR;
import org.weasis.dicom.codec.utils.DicomMediaUtils;
import org.dcm4che3.img.util.DicomUtils;

public class SOPInstanceReference extends Module {

Expand All @@ -43,7 +43,7 @@ public static Collection<SOPInstanceReference> toSOPInstanceReferenceMacros(Sequ
}

public int[] getReferencedFrameNumber() {
return DicomMediaUtils.getIntArrayFromDicomElement(dcmItems, Tag.ReferencedFrameNumber, null);
return DicomUtils.getIntAyrrayFromDicomElement(dcmItems, Tag.ReferencedFrameNumber, null);
}

/**
Expand Down
Loading

0 comments on commit 64c4603

Please sign in to comment.