Ask Your Question
0

Is there a way to rotate an image and then fill the resulting empty space with a certain color?

asked 2013-10-05 15:18:37 -0500

jhnwllr gravatar image

When I rotate an image using...

img.rotate(ang, fixed=False, point=[-1, -1], scale=1.0)

the resulting corners of the image always fill with black. Is there a way to fill the extra space with white or some other color?

edit retag flag offensive close merge delete

Comments

HI there You can try to this code: using RasterEdge.Imaging.Basic; using RasterEdge.Imaging.Basic.Core; using RasterEdge.Imaging.Processing; using RasterEdge.Imaging.Basic.Codec; namespace RE__Test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string fileName = "c:/Sample.png"; REImage reImage = REFile.OpenImageFile(fileName); ImageProcessing.ApplyRotate(reImage, 60); REFile.SaveImageFile(reImage, "c:/reimage.png", new PNGEncoder()); } } } http://www.rasteredge.com/how-to/csharp-imaging/rotate-image/ Or just visit this site.There is detailed tutorial:

Donna111 gravatar imageDonna111 ( 2013-10-24 01:15:40 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-10-07 11:47:00 -0500

By default, there is no command to do what you want,

but you can solve it easily!

simply upload an image with the color you want to appear and do the following:

from SimpleCV import Camera, Image,Color
import time

cam = Camera(1)
img = cam.getImage()
vermelho = Image('/home/administrador-x/vermelho.png').resize(img.width,img.height)
rotate = img.rotate(-65)


mask = rotate.hueDistance(color=Color.BLACK,minsaturation=1,minvalue=1).erode(3).binarize(254)


img2 = mask+vermelho.invert()
img3 = img2.invert()+rotate

img3.show()
time.sleep(5)

see a example image with red color:

image description

edit flag offensive delete link more

Comments

Thanks, but this isn't really a great solution, since you are still leaving a large black border around your original image. I used the embiggen to increase the canvas size and then cropped the image.

jhnwllr gravatar imagejhnwllr ( 2013-10-07 17:14:18 -0500 )edit

excuse me, but did not quite understand quiz What do u mean, I'm using a translator to translate what you wrote, and he returned a few meaningless words, retype look not use abbreviations in the words!

Rodrigo gomes gravatar imageRodrigo gomes ( 2013-10-08 12:26:32 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-10-05 15:18:37 -0500

Seen: 329 times

Last updated: Oct 07 '13