Saturday 15 August 2015

python - Increasing image width by one pixel -


I am trying to apply a program, which would increase the width of the image by a pixel. I then want to take the new max x coordinate and put it in a random y coordinate (within the image's limit) to make it a new pixel.

  x (0, GetWidth (pic)) Category: y (0, getHeight (pic)) Category: X = getWidth (pic) newX = (X + 1) colr = (255,0,0) newPixel = getPixel (pic, newX, Y) // line 25 caller (new pixel, color) Y = Milnafiit (pixel) new Email = (y + 1) new pixel = union pixels (picture X, Nuy) caller (Nupiksel, color)   

I get this error:

  getPixel (image, x, y): x ( = 226) is greater than 0 or greater than (= 224) error: Incorrect argument value (of the right type) to argue on a function There was an error in the attempt. Please check the Line 25 of D: \ bla bla   

I think it is out of bounds What am I doing wrong?

Here's generalized approach to increase the size of an image to an existing image:

Feel free to optimize.

  Raise the image given to # offset, whether a color and unicast # should be centered or not. # Offset should be positive Def increaseAndCopy (pic, offsetX, offsetY, bg_color = black, center = true): # Offset should be positive (offsetX & lt; 0.0) or (offsetY & lt; 0.0): printNow ("Error: Offset must be positive! ") return any Ni_v = pic.getWidth () + int (2 * offsetX) new_h = pic.getHeight () + int (2 * offsetY) startX = 0 startY = 0 if (center) and (OffsetX & Gt; 1.0): startX = Int (offsetx) if (center) and (offset y> 1.0): startY = int (offsetY) new_pic = makeEmptyPicture (new_w, new_h) # fill with background color setAlpixelTooler (new_pic, Bg_color) Process for x in xrange Mr. Copy .getWidth ()): In xrange for y (pic.getHeight ()): px = getPixel (pic, x, y) new_px = getPixel (new_pic, x + startx, y + startY) caller (new_px, Getcolor (px) Returns new_pic file = pickAFile () Picture = Makepackure (file) Passing an offset of 0.5 to increase from # 1 pixel #nu_picure = increase and copy (image, 0.5, 0, blue) new_picture = increaseAndcopy (image) (New_picture): write the image (new_view, "/ home / large ARPIC page"), (new image)   


output (< Em> Gene-Michel Busquet Door Painting ):


................  Enter image details here ...........................  Enter image details here ................


< / Div>

No comments:

Post a Comment