pyqtgraph histogram find and set colour automatically - python-3.x

I have a pyqtgraph imageitem with an associated histogram. I can change the colour of the image by selecting it from the histogram. What I want to do is save the name/number/something of this process so that I can later create the image and automatically load this colourmap using just this information.
How do I do this?
I can see the values of the colourmap in LUT but saving 512 x 3 values is a bit too much for me. I would really appreciate a better solution.

I found an alternative way to do this. When I click on the colourmap I record the selection in the program and can then use this whenever I want.

Related

Changing colors in a simple shape editior

I've made a simple shape editor. I can change colors (used to fill shapes) by click on buttons in a menu bar. The disadvangate of this solving is the fact that the numbers of colors are so restricted. I can't find a better solution for my program. Can somebody help me and give me an idea how can I improve it? I thought about color palette, but I have no idea how can I do this.
The image:
("Aktywny kolor" means active colors, and there is the list of colors below, which I can use)
You would need to use a color picker where the colors are distributed on many pixels and not on a very small set of color names. Since you are using applet, you might want to download an already made color picker compatible with your environment, or you might want to write your own, depending on whether the things you find meet your expectations.

change dicom image's window width and window level

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().

Creating an image whith GIMP hiding another image unless we add a color filter in real life

The idea is like the inverse of Ishihara test (http://www.colour-blindness.com/colour-blindness-tests/ishihara-colour-test-plates/).
I want to create with GIMP an image that showing something and then if I add a color layer, for exemple green glasses, then I see something new appearing.
I've searching far in Google and so but didn't found anything. Do you know how would I make this?
The Ishihara tests use the principle of combining things color blind persons cannot differentiate.
Coloured glass filters will only remove other colours from what you see. They don't add something. Therefor it is not possible to create a digital image that contains no information unless seen through a colour filter.
The only thing you can do is overlap your "hidden" information with high contrast colour noise.
Like here:
Using the glasses / filter only improves the visibility. The information is not added. It was always there.

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);

Create Editable plots from R

I'm creating a series of plots in R (I'm using ggplot2, but that's not essential) and I want to be able to save my output so I can then edit it for furthur use, For instance, I might want to move legends about, or adjust colours etc. I have seen that ggplot2 has a save command but that seems to produce pdf's or bitmaps, neither of which are particularly editable
How do other people do this ? Any good ideas ?
Here's some sample code to produce a sample plot;
library(ggplot2)
dataframe<-data.frame(fac=factor(c(1:4)),data1=rnorm(400,100,sd=15))
dataframe$data2<-dataframe$data1*c(0.25,0.5,0.75,1)
dataframe
testplot<-qplot(x=fac, y=data2,data=dataframe, colour=fac, geom=c("boxplot", "jitter"))
testplot
Thanks
Paul.
Other editable formats:
Take a look at help(devices) for other formats which are available: these include svg, pictex and xfig, all of which are editable to greater or lesser extents.
Note that PDFs can be edited, for instance using the Omnigraffle tool available for Apple's OSX.
Other ways to record plot data:
In addition, you can record R's commands to the graphics subsystem for repeating it later - take a look at dev.copy:
Most devices (including all screen devices) have a display list
which records all of the graphics operations that occur in the
device. 'dev.copy' copies graphics contents by copying the display
list from one device to another device. Also, automatic redrawing
of graphics contents following the resizing of a device depends on
the contents of the display list.
Using Rscript to create a repeatable, editable plot:
I typically take a third strategy, which is to copy my R session into an Rscript file, which I can run repeatedly and tweak the plotting commands until it does what I want:
#!/usr/bin/Rscript
x = 1:10
pdf("myplot.pdf", height=0, width=0, paper="a4")
plot(x)
dev.off();
With ggplot and lattice, you can use save to save the plot object to disk and then load it later and modify it. For example:
save(testplot, file = "test-plot.rdata")
# Time passes and you start a new R session
load("test-plot.rdata")
testplot + opts(legend.position = "none")
testplot + geom_point()
Thanks for the answers, I've played around with this, and after some help from my friend Google I found the Cairo package, which allows creation of svg files, I can then edit these in Inkscape.
library(Cairo)
Cairo(600,600,file="testplot.svg",type="svg",bg="transparent",pointsize=8, units="px",dpi=400)
testplot
dev.off()
Cairo(1200,1200,file="testplot12200.png",type="png",bg="transparent",pointsize=12, units="px",dpi=200)
testplot
dev.off()
Now I just have to play around with the various settings to get my plot as good as it can be before writing the file.
right click the mouse on the output plot
Copy as metafile
then save plot into a word document (right click to edit picture to covert to the plot to Microsoft Office drawing Object)

Resources