Dear James,
Thank you very much for your response.
I have modified the code as follows:
r1, g1, b1 = img.split()
r2, g2, b2 = img1.split()
outR = ImageMath.eval("(a + b)", a=r1, b=r2)
outG = ImageMath.eval("(a + b)", a=g1, b=g2)
outB = ImageMath.eval("(a + b)", a=b1, b=b2)
out = Image.merge("RGB", (outR, outG, outB))
But, I am getting the same error "*Value Error: Needs more than one value to
unpack*"
Can you suggest any remedy?
With Warm Regards,
Bishwarup
On Mon, Oct 19, 2009 at 8:15 PM, James Tedrick <[email protected]> wrote:
> the problem is your first 2 lines- take them out.
>
> Also, your merge syntax is incorrect
> outImage = Image.merge("RGB", (outR, outG, outB))
>
> will be the correct statement. You also won't need the Image[R] type
> statements
> james
>
> On Mon, Oct 19, 2009 at 9:50 AM, Bishwarup Banerjee
> <[email protected]> wrote:
> >
> > Dear James,
> > Sorry for disturbing you once more.
> >
> > I modified the statement as follows:
> >
> > R, G, B = 0, 1, 2
> > Image1 = img.split()
> > r1, g1, b1 = img.split()
> > r2, g2, b2 = img1.split()
> > outR = ImageMath.eval("(a + b)", a=r1, b=r2)
> > outG = ImageMath.eval("(a + b)", a=g1, b=g2)
> > outB = ImageMath.eval("(a + b)", a=b1, b=b2)
> >
> > Image1[R].paste(outR, None)
> > Image1[G].paste(outG, None)
> > Image1[B].paste(outB, None)
> >
> > out = Image.merge(img.mode, Image1)
> >
> > But, now I started getting error, in the 1st split line.
> > It says"Value Error: Needs more than one value to unpack"
> >
> > Can you tell me what is causing this?
> >
> > With Regards,
> > Bishwarup
> >
> >
> >
> > On Mon, Oct 19, 2009 at 6:06 PM, James Tedrick <[email protected]>
> wrote:
> >>
> >> take a look at the split syntax- it assigns the band to a set of
> single-band images.
> >>
> >> this should work:
> >> r1, g1, b1 = img1.split()
> >> r2, g2, b2 = img2.split()
> >>
> >> outR = ImageMath.eval("a+b", a=r1, b=r2)
> >>
> >> etc
> >>
> >> On Mon, Oct 19, 2009 at 7:54 AM, Bishwarup Banerjee <
> [email protected]> wrote:
> >>>
> >>> Dear James,
> >>> I tried the following code
> >>>
> >>> R, G, B = 0, 1, 2
> >>> Image1 = img.split()
> >>> Image2 = img1.split()
> >>> outR = ImageMath.eval("(a + b)", a=Image1[R], b=Image2[R])
> >>> outG = ImageMath.eval("(a + b)", a=Image1[G], b=Image2[G])
> >>> outB = ImageMath.eval("(a + b)", a=Image1[B], b=Image2[B])
> >>>
> >>> Image1[R].paste(outR, None)
> >>> Image1[G].paste(outG, None)
> >>> Image1[B].paste(outB, None)
> >>>
> >>> out = Image.merge(img.mode, Image1)
> >>>
> >>> I am using this code for adding the values of pixels from two different
> images. But again I am getting the same error, as mentioned in my previous
> mail. Only time I am not getting the error is when i am converting the
> images to "L", before performing eval.
> >>> Please help me out, I dont know where I am wrong.
> >>>
> >>> With Warm Regards,
> >>> Bishwarup
> >>>
> >>> On Mon, Oct 19, 2009 at 4:49 PM, James Tedrick <[email protected]>
> wrote:
> >>>>
> >>>> use (image).split out the multi-band into the single bands and
> Image.merge again afterword- take a look at
> >>>> http://www.pythonware.com/library/pil/handbook/introduction.htm under
> "Cutting, pasting..."
> >>>>
> >>>> james
> >>>>
> >>>> On Mon, Oct 19, 2009 at 6:02 AM, Bishwarup Banerjee <
> [email protected]> wrote:
> >>>>>
> >>>>> Dear James,
> >>>>>
> >>>>> Thank you very much for your reply. I tried that but i get the
> following error
> >>>>>
> >>>>> ValueError, unsupported mode, P
> >>>>> I am trying to find a solution, it may be due to multi band image. In
> the mean time If you have solution to this problem please reply back.
> >>>>>
> >>>>> With Warm Regards,
> >>>>> Bishwarup
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> On Fri, Oct 16, 2009 at 6:23 PM, James <[email protected]> wrote:
> >>>>>>
> >>>>>> The ImageMath Module should take care of it (works on single-band
> >>>>>> images, which is what it sounds like you've got):
> >>>>>>
> >>>>>> (slight mod of demo)
> >>>>>> import Image, ImageMath
> >>>>>>
> >>>>>> im1 = Image.open("image1.jpg")
> >>>>>> im2 = Image.open("image2.jpg")
> >>>>>>
> >>>>>> out = ImageMath.eval("a + b", a=im1, b=im2)
> >>>>>> out.save("result.png")
> >>>>>>
> >>>>>> james
> >>>>>>
> >>>>>> On Oct 16, 3:32 am, Bishwarup <[email protected]> wrote:
> >>>>>> > Dear All,
> >>>>>> >
> >>>>>> > I am new to PIL and python. I am in the process of developing a
> plugin
> >>>>>> > for image processing. In this I need to modify each pixel of an
> image,
> >>>>>> > then combine the images to form a new image. The pixel values of
> the
> >>>>>> > new image will be summation of the pixel values of all the images
> at
> >>>>>> > that particular location.
> >>>>>> > Can this be achieved through PIl and python, If yes then how?
> >>>>>> > I am using PIL 1.1.6, python 2.5 and windows
> >>>>>> > Thank you in advance.
> >>>>>> > With Regards
> >>>>
> >>>
> >>
> >
>