i can’t upload the segmentation image with the main image
i got the segmented image after the treatment (output test )
where the dimensions of main image and segmented are not the same
but I want to combine main image with segmented image
any solution please to match the segmentated image with the main image?
i tried to match the message displayed is "the size of segmentation image does not match with main image images must have the same dimensions"enter image description here
You can need to resample the image into the same size as the original image - assuming your segmentation is in the same origin as the input image this function should do that.
import SimpleITK as sitk
def resample_image(input_img, input_seg, is_label=False):
dimension = 3
original_spacing = itk_image.GetSpacing()
original_size = itk_image.GetSize()
resample = sitk.ResampleImageFilter()
resample.SetOutputSpacing(original_spacing)
resample.SetSize(out_size)
resample.SetOutputDirection(input_img.GetDirection())
resample.SetOutputOrigin(input_img.GetOrigin())
resample.SetTransform(sitk.Transform(dimension, sitk.sitkIdentity))
resample.SetDefaultPixelValue(input_img.GetPixelIDValue())
if is_label:
resample.SetInterpolator(sitk.sitkNearestNeighbor)
else:
resample.SetInterpolator(sitk.sitkBSpline)
return resample.Execute(itk_image)
Related
Does it add to the image if too small or crop if too big or just stretch the image to the desired size?
When you set interpolation=2, then you are using Bilinear interpolation, ti can be either used for upsampling or down sampling. In the case of upsampling you are doing something like
There are several types of upsampling and down-sampling, but bilinear one uses a combination of the neighbouring pixels to cimpute the new pixel.
Look to this links for more informations: link1; link2
Resize stretches the image to span the new size. It samples from the original image using the provided interpolation method.
I'm trying to put a picture in my python game, so far I have this:
picture = pygame.image.load(picture.jpg)
screen.fill(BLACK)
screen.blit(picture, (0,0))
This successfully adds the picture, but takes up the whole screen. Is it possible to reduce the size of this picture?
Thank you for the help.
It looks like you can scale an image with transform.scale.
picture = pygame.transform.scale(picture, (1280, 720))
Also have you tried playing around with the parameters in screen.blit?
I think instead of passing a point into the "Dest" parameter you can pass a rectangle.
screen.blit(picture), (0,0,width,height))
In a qtextedit with html I am changing the fontsize via the mousewheel.
It should change the size of each character, e.g.+1 or -1.
It works, slowly, but it works. The problem is now if I change the size of a html list (created via QTextCursor.createList()). As you see in the picture, the "Test" after resizing always starts at the same position (as intended), but the black points move. I'd like them to stay on the same position no matter how big the text is. I have no clue how to do that, I already tried setMarging, setIndent, setTextIndent...
def change_fontsize(self, direction):
cur=self.textedit.textCursor()
oldPosition=cur.position()
if cur.hasSelection():
begin=cur.anchor()
end=cur.position()
if begin>end:
helper=end
end=begin
begin=helper
else:
cur.select(QTextCursor.Document)
begin=0
plainText=self.textedit.toPlainText()
end=len(plainText)
for i in range(begin,end):
cur.setPosition(i)
cur.movePosition(QTextCursor.NextCharacter, QTextCursor.KeepAnchor)
fmt=cur.charFormat()
charSize=fmt.fontPointSize()
if direction=="up":
fmt.setFontPointSize(charSize+1)
else:
fmt.setFontPointSize(charSize-1)
cur.mergeCharFormat(fmt)
I want to add a plot to my first page of the (HTML5) slide. Can I achieve this in a dynamically way? Say, the background image will be generated by R code, rather than insert a semi-transparent PNG image. Thank you.
Update: What I want is
You can use the chunk option dev.args to achieve this. You will need to size the image correctly to fit your slide.
```{r dev.args = list(bg = 'transparent')}
plot(1:10, 1:10)
```
This chunk will generate a transparent png. Please read the documentation ? png to get a list of arguments you can pass. Here is one useful piece onf info from the docs.
png supports transparent backgrounds: use bg = "transparent". (Not all PNG viewers render files with transparency correctly.)
UPDATE. For plots using ggplot2, the alpha parameter can be used to control transparency.
```{r dev.args = list(bg = 'transparent'), echo = F, comment = NA, message = F}
library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
geom_point(alpha = 0.1) +
geom_smooth(alpha = 0.1)
```
UPDATE2. To use a dynamic image as background, you need to set the background of the slide dynamically. This can be easily achieved in slidify [Disclosure: I am the author]
Here is a gist with an Rmd file which when slidified will give a transparent background.
I wish to print a chart.
I do as follow :
var printJob : PrintJob = new PrintJob();
if ( printJob.start() == false )
return;
var printOptions : PrintJobOptions = new PrintJobOptions( true );
printJob.addPage( lineChart, null, printOptions );
printJob.send();
but as a result i am receiving only 1 page which containing only some part of the chart.
How to scale the whole chart on 1 page, and how to print all of the chart pages when it is not scaled ?
Alive PDF or Pure PDF or FxPDF is one of the best solutions to create cutom printings.
http://alivepdf.bytearray.org/
http://code.google.com/p/purepdf/
You only get one page because you add only one page:
printJob.addPage( lineChart, null, printOptions );
Your chart clip must fit on a page, A4 dimension in pixels should fit in width:559 x height:842.
You can check the dimensions of your chart clip, when it is bigger then the A4 you can scale it accordingly (don't forget print margins). To scale a movielclip you can use scaleX or scaleY, but changing the width or height of the container works better for me, because pixel values are easier then calculating the scale.
You can also create a print template clip, so instead of printing the chart clip immediately you place the charts on a new clip, that way you have more control over the page you are printing. It will also be easier to add more pages to the printjob.