globalbalance - bug?
I am mosaicing (i also tried merge) 2 images and then i want to do globalcontrast:
right = pyvips.Image.rawload(f'{r}/[0017][0015].dump',1920,1200,2).copy(bands=1, format="ushort", interpretation="b-w")<< 6
left = pyvips.Image.rawload(f'{r}/[0017][0016].dump',1920,1200,2).copy(bands=1, format="ushort", interpretation="b-w")<< 6
join = left.mosaic(right, "horizontal", M2.width - 102, 0, 0, 0,harea=15, bandno=0)
balance = join.globalbalance()
balance.pngsave('merged.png')
But it seems that no matter i do i get:
Error: unable to call globalbalance
im_global_balance: unable to open "temp-6356"
What is going wrong here?
It's just the way globalbalance works. Images have to come from files that it can reopen, so they need to be tiff / vips / png sources, something like that.
ok - so if i have raw sources it will not work? I tried changing my sources to tiff - and then i dont get the error. I can then actually also merge them and still looks okay (except for the brightness difference in the tiles), but if I use the globalbalance now I just get a blank image (no errors). Am I doing something wrong?
Here is the code:
right = pyvips.Image.tiffload(f'{r}/[0017][0015].tiff')
left = pyvips.Image.tiffload(f'{r}/[0017][0016].tiff')
join = left.merge(right,'horizontal',1920-102,0,mblend=100)
balance = join.globalbalance()
balance.tiffsave('merged.tiff')
(Also - how do I choose a suitable mblend value?)
Ok, i managed to make it work, but for some reason the globalbalance is not doing what i expected it will do. Seems like tiles are still varying levels of brightness for some reason.
Here is how i did
bimg = None
for i in [19,18,17,16]:
rowtile = None
for j in [17,16,15,14]:
fn = f'{r}/[{str(i).zfill(4)}][{str(j).zfill(4)}].tiff'
tile = pyvips.Image.tiffload(fn)
rowtile = tile if not rowtile else rowtile.merge(tile, "horizontal",1920-102,0,mblend=-1)
bimg = rowtile if not bimg else rowtile.merge(bimg, "vertical",0,1200-119,mblend=-1)
balance = bimg.globalbalance()
balance.pngsave('merged.png')
Am I doing something wrong here?
You've not fixed your vignetting -- global balance just adjusts the overall brightness of tiles, it won't be able to adjust pixel by pixel.
You could possibly take lens-cap black too. It would also be worth testing your camera gamma -- is it sRGB or linear?