change dicom image's window width and window level - linux

Recently, I am working on process dicom image怂I don't know how to change the WWWL of a dicom image. Also, I use dcmtk to convert dicom image to bmp and show it(I didn't use vtk to show the image). I really don't know if that is correct.
I want to know the algorithm which can help me change the dicom image's window width and window level automatically. I didn't find the corresponding algorithm while I was using dcmtk.
thanks and regards.

If you want to specify the values of Window Center and Width (aka VOI transformation or windowing) manually, you can use DicomImage::setWindow() for this purpose. If you want to specify an automatically computed min-max window, you could use DicomImage::setMinMaxWindow().

Related

Resizing a canvas to the size of a pasted-in image when the pasted-in image is larger than the canvas

First, I know this is a terrible workflow; it's being enforced on me by my employer's SDL Tridion Docs content management system, which seems to specialize in showing complete contempt for its users.
I need to open a raster image in Gimp, paste in a new image, resize the canvas, save and close. This works fine when the pasted-in image is smaller than the original image, but when the pasted-in image is larger I cannot for the life of me find a function to detect the size of the pasted-in image and expand the canvas to fit; all of the functionality seems to assume that the new image will be smaller. I'm looking for the equivalent of the "resize document to selection" command found in Inkscape.
If you do this manually, see Image>Fit canvas to layers.
If you do it in a script, pdb.gimp_image_resize_to_layers(image) in python, something similar in Script-fu.

How to clip/crop an image with AsciiDoctor

Is there some way (besides writing a plugin) to clip/crop an image which is inserted into an AsciiDoc document?
I couldn't find such a feature in the docs but there might be a plugin I am not aware of...
No, there is no such feature. When you use the image: macro, you can set the image's width and height, but there is no option to set the crop area or starting point for cropping. See https://asciidoctor.org/docs/user-manual/#images for details.
To crop the images, you might need to perform some sort of pre/post processing to directly crop the images. Unless you have a requirement to dynamically crop the image, it's probably best to do so manually.
If you do need the ability to dynamically crop images, you might create a plugin that creates a new macro, say crop:, that uses the image: macro's internals, but accepts crop coordinates and performs the cropping on the source image.

vtkImageViewer2 not rendering until I reset

I've showed a dicom image successfully with vtkImageviewer. Then I realized that vtkImageviewer2 would be more suitable, as I needed interactors and load images with slices, maybe 3d, etc
So I changed to vtkImageviewer2. Then I just see a white image. All white.
But my surprise was that, adding the render window interactor, when I press r... the image appears! So I looked into the class code. I saw the reset event and how it sets color window and color level. I've tried doing this, with poor results.
Why do I have to reset the window/level to see the image? I can do zoom, and rotate... around the white plane.
I did a widget->Update() or a imageViewer->Render() with the same result.
The Window Width/Level value is not computed initially, the default values are W255/L127.
It is necessary to set appropriate values. i.e. from Dicom Header Information or compute them by yourself.
myVtkImageViewer2->SetColorWindow(myWidthValue);
myVtkImageViewer2->SetColorLevel(myLevelValue);
Setup window/level values from your vtkImageActor:
vtkImageActor->GetProperty()->SetColorWindow(20);
vtkImageActor->GetProperty()->SetColorLevel(10);

How to display a .bmp in an NSImageView for MacOs so that a certain color is transparent?

I have some .bmp files that have some color (maybe black) that is supposed to show as transparent when the graphic is displayed on top a form, so the form color comes through the transparent areas. But by default, when I put these images in an Image View, the black/transparent areas show up as BLACK!
I'm thinking I need to either:
- alter how the NSImageView shows the image, so that a certain color is transparent, or
- modify the .bmp files somehow to make that color suitable for transparency in an NSImageView
But I don't know enough about graphics files, transparency(alpha), NSImageView, nor the image editing tools. I'm trying to use Gimp, but...not sure what I'm doing yet. It seems like there is already a color that should be transparent in the current .bmp file.
I'm sure its something simple for setting NSImageView, or editing my file, or perhaps making a mask for the image, but I don't know how yet. I've looked at various filters in IB for NSImageView, but have not found where to set the transparent color, nor how to grab that color from the image file to make sure I use the correct value.
Thanks in advance for any assistance. (I tried to post some images, but because I'm new, I could not.)
Beau
I'm not a Cocoa developer, but in Gimp try adding an alpha channel to your image (a layer mask, perhaps) then saving as a 32-bit PNG image (with an alpha channel), then load that PNG directly into your NSImageView. If you want to make the black pixels transparent in Gimp use the magic-wand tool to select them (use magic-wand with 0 tolerance) and just delete the contents of the selection then save as a PNG directly.

Pixlelated borders when i save image as GIF with Transparent In Illustrator

World Map Images in Adobe Illustrator CS5
I have an image Map in illustrator CS5 which i want to save in GIF so as to reduce its size for web use. But when i save it, the map boundaries are having some white pixels all along the map boundaries of map.
I really dont know why has happened to it, but cant save it in Png-8, png-24 formate due to size constraint.
Any meaningful answer will be highly appreciate and thanks in advance.
Is your background a non-changable color? Maybe you can save the image with the same color as a background.
The problem is gifs don't support true transparency.
If this doesn't work can you provide the image you are trying to save (gif and png, I don't have AI right now)? Maybe there will be something I can do about the size or clearing the gif's edges.
transparent GIFs don't have an 8-bit alpha channel, like PNG does: a pixel in a GIF is either there, or it's not: if it's there, you can't see through it. This often means that an edge between transparent and non-transparent areas looks blocky.
There are two ways to deal with this... either use a PNG 24 (and the Illustrator Save for Web feature will help you to make it smaller), or in Illustrator create a background color layer behind your image before you export to GIF. If this background color layer is the same as the website you put the image on, the edges will blend nicely.

Resources