Convert tiff to dicom using Matlab - matlab

I have a series of dicom images and did change the HUs in the images using MATLAB scripts, then I imported them in ImageJ for display. Then I realised I can modify the images using ImageJ gui (which much easier, just moving the mouse). However, when I saved the modified images in ImageJ, they were saved in tiff format.
My question is that, is there a way to save images in imageJ as dicom format ?
or is there away to convert tiff format to dicom using MATLAB ?
Any suggestion ?

You can convert tiff format to dicom with dicomwrite:
dicomwrite( imread('input_image.tif'), 'output_image.dcm')

The following plugins allow writing DICOM files directly from ImageJ:
DICOM Import and Export plugins
The Tudor DICOM Tools

Related

How to open a .img/.rrd satellite image in Matlab?

I have a couple of multispectral satellite images which are in .img/.rrd format and I want to oopen them in Matlab for further processing.
I'm not sure Matlab can recognise .img /.rdd files directly, but you could try using ImageJ or Fiji to convert your .img files to one of the image formats that is accepted. e.g. tiff, png, bmp, jpeg. The list of accepted formats can be found by typing 'imformats' in the command line.

Convert from TIFF to PNG using Windows?

Is there a way to convert all TIFF images to PNG using windows console or any simple tool.
I renamed tags, but the problem now is file size. What are ways to compress files?
imagemagick, it's CLI tool for image manipulation available for most major operating systems including Windows http://www.imagemagick.org/script/download.php
It's very simple to use it
convert in.tiff out.png
To convert and scale by 50%:
convert in.tiff -resize 50% out.png
Here you can find full list of general commands
TinyPng is great to compress png files, you can try that.
www.tinypng.com

Artifacts appear using imread function from opencv

I use imread function to read one jpeg file and save the rgb image in bmp format. Comparing the two files, I found artifacts appear and use green circle to denote artifacts. The version of OpenCV is 3.0. I compile the libraries by myself with SSE, SSE2 and SSE3 switchd on (default setting). My OS is windows 7 professional. You can use the following image to check.
original jpeg image
saved bmp file
If I read the jpeg file in Matlab, the rgb image is correct. I save rgb image in png format in Matlab, read the png file using opencv and save the loaded image in bmp file. Everything is OK. It seems that there is a problem with jpeg decoder. The jpeg library used is libjpeg.lib.
Due to the size limit, I cut the patch from the second image.
You're always going to get some artifacts in JPEG. You can reduce the appearance of such artifacts by changing the quantization tables used (usually with loss of compression).
JPEG encoders often use a "quality" setting to change the quantization tables.

Convert dicom .dcm files into .obj format

I have sets of .dcm files of an MRI scan. I am trying to convert them into 3d formats like obj (preferably) or fbx to import them into Unity 3d. I used the following open source software dcmtk to convert .dcm file into text file.
Converting DICOM files to text files
However, the dcm files lack the needed information. Is it even possible to convert .dcm files to obj and fbx. if so, could you suggest something?
Thanks
(Edit)
I would like to put my question more precisely: I want to visualize MRI data as a 3D model in Unity 3d. This is possible only when I it stored as .obj or .fbx format. Which format of MRI medical data should I start with to convert to these formats?
Thanks
According to your previous comments you are looking for the necessary information in order to obtain the geometrical information of a DICOM series representing volumetric information (RM, TC, PET, ...)
In this case, you should have a look at the Roni Zaharia web site where he explains very clearly the concepts related to orientation and geometry of the DICOM images: DICOM is easy: Getting oriented
In this particular page you will find information about Pixel Spacing, Image Orientation, Image Position, Slice Thickness, and Slice Location, as well as additional information references.

Matlab: How to save plots of patches / fill() automatically in the code?

quick question: I'm creating "random" polygons using either the patch() or the fill() function in Matlab. This works quite good and it is plotted correctly.
However, I need to at least save a few hundres polygons as images to my hard drive for working with them later - so I'm looking for a way to directly save the image in my function rather than saving each polygon myself using the file-menu.
Is there any way to do this?
Thanks in advance!
You can indeed use the print function, but I would not use the jpeg device. JPEG is never the right format for plots (you will get a lot of artifacts near all your lines).
If you need a bitmap image, try the png or tiff device. If you don't need a bitmap, use the appropriate vector image format: fig is the native MATLAB format (which allows you to edit the plot afterwards), so this is the best one if you stick with MATLAB for all your operations. For exporting to other software, I would recommend pdf (works almost anywhere), epsc (EPS with color, great for LaTeX or inkscape), wmf/emf (Windows Metafile, so Windows only, but great for including the images in MS Office). Or you could of course use any of the other formats mentioned in the print documentation.
Sometimes it's a pain in the neck to get the format of your image all right (especially with PDF output). Just take a look at the different properties of your figure and more specifically the PaperSize, PaperUnits and PaperPosition.
The easiest way, and I guess the best solution, is to save as a .fig file. You can do this by using saveas:
h = figure;
% your plot commands here
saveas(h,'mFile.fig');
Afterwards, you can reload the image with the openfig function:
openfig('mFile.fig');
Have to add this answer. This function is helping a lot.
This function saves a figure or single axes to one or more vector and/or bitmap file formats, and/or outputs a rasterized version to the workspace, with the following properties:
   - Figure/axes reproduced as it appears on screen
   - Cropped/padded borders (optional)
   - Embedded fonts (pdf only)
   - Improved line and grid line styles
   - Anti-aliased graphics (bitmap formats)
   - Render images at native resolution (optional for bitmap formats)
   - Transparent background supported (pdf, eps, png)
   - Semi-transparent patch objects supported (png only)
   - RGB, CMYK or grayscale output (CMYK only with pdf, eps, tiff)
   - Variable image compression, including lossless (pdf, eps, jpg)
   - Optionally append to file (pdf, tiff)
   - Vector formats: pdf, eps
   - Bitmap formats: png, tiff, jpg, bmp, export to workspace