1.
A simple and easy way is to use the 3D slicer.
It can convert general images to dicom secondary capture with some primary attributes.
2.
If you would contribute/try programming,
for example (This procedure is not strict.),
//get image pixels as byte[]
BufferedImage bmp = ImageIO.read(new File("your.bmp"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write( bmp, "bmp", baos );
byte[] pixels = baos.toByteArray();
baos.flush();
baos.close();
//get dicom attr reference to copy
DicomInputStream dis = new DicomInputStream(new FIle(path2ReferenceDcm));
Attributes refDcm4AttrCopy = dis.readDataset();
dis.close();
//set pixel
refDcm4AttrCopy.setValue(Tag.PixelData, VR.OW, new BulkData(pixels)); //should check VR.OB or OW.
//set attr values related to pixel
refDcm4AttrCopy.setInt(Tag.Rows,
VR.US, bmp.getHeight());
refDcm4AttrCopy.setInt(Tag.Columns,
VR.US, bmp.getWidth());
refDcm4AttrCopy.setInt(Tag.BitsAllocated, ...)
refDcm4AttrCopy.setInt(Tag.BitsStored, ...)//BitsStored - 1
refDcm4AttrCopy.setInt(Tag.HighBit, ...)
refDcm4AttrCopy.setInt(Tag.PixelRepresentation, ...)
refDcm4AttrCopy.setInt(Tag.SamplesPerPixel, ...)
refDcm4AttrCopy.setInt(Tag.PhotometricInterpretation, ...)
// set secondary capture sop class uid
refDcm4AttrCopy.setString(Tag.SOPClassUID, ...)
//set uids
refDcm4AttrCopy.setString(Tag.StudyInstanceUID...);
refDcm4AttrCopy.setString(Tag.SeriesInstanceUID...);
refDcm4AttrCopy.setString(Tag.SOPInstanceUID...);
//create file meta info
Attributes fmi = refDcm4AttrCopy.createFileMetaInfomation(Tag.SOPClassUID);
//output
DicomOutputStream dos = new DicomOutputStream(new File("path2BmpAsDicom.dcm"));
dos.writeFileMetaInformation(fmi);
attribs.writeTo(dos);
dos.close();
You can keep in mind,
- Is that bmp compressed or not ? if compressed, decompress it first, then use it as ExplicitLittleEndian for TSUID.
- Is multiframe ? (movies ?)
- gray or rgb ? if rgb, what is order ? (which rrr...ggg...bbb... or rgbrgbrgb...), if grascale, has look up tables ?
- bit-depth ? (8 bit or 16 bit or more grayscale?, or 24 bit , 32 bit rgb ?)
I hope this helps.
(Notice, I am not dcm4che developer)