Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 24th August 2010, 20:24   #1  |  Link
AviUser
Registered User
 
Join Date: Mar 2009
Posts: 39
Process only rectangle in image? [SOLVED]

Hi,

My video has a "bright" line on the right edge of the video throughout the whole video. See this image (note part of image was cut out): [link removed]
I want to darken only this line, but using Crop and Overlay seems very inefficient.

Does anyone know how to do it more elegantly?

Thanks in advance!

Last edited by AviUser; 25th August 2010 at 19:37. Reason: SOLVED
AviUser is offline   Reply With Quote
Old 24th August 2010, 23:08   #2  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Code:
Top=Crop(0,0, 0,32)
Mid=Crop(0,32, 0,-32)
Bot=Crop(0,Height()-32, 0,0)

Left=Mid.Crop(0,0 32,0)
Cent=Mid.Crop(32,0, -32,0)
Right=Mid.Crop(Mid.Width()-32,0, 0,0)

NewCent=Cent.Filter(...) # process as required

NewMid=StackHorizontal(Left, NewCent, Right)
StackVertical(Top, NewMid, Bot)
Of course choose numbers other than 32 that suit your image.

And of course you could process Top, Bot, Left and/or Right if you want to leave the middle and do the edges.

Crop() is a zero cost filter, it just does pointer arithmetic as the graph is compiled.

The Stack*() filters cost 1 Bitblt, i.e. the standard minimal not in place filter processing cost.
IanB is offline   Reply With Quote
Old 24th August 2010, 23:37   #3  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Sorry for thread hijack, but it's a related question:

How would you do a feathered overlay , such that the edge transition isn't so abrupt?

I read this thread: and there is a way using alpha channel and bluring mask edge, but just wondering if there is another approach?
http://forum.doom9.org/showthread.php?t=155937

and AviUser - if you post your images at a 3rd party site, you don't have to wait for mod approval (e.g. imageshack.us, imagebam, tinypic etc...)
poisondeathray is offline   Reply With Quote
Old 24th August 2010, 23:47   #4  |  Link
AviUser
Registered User
 
Join Date: Mar 2009
Posts: 39
Thanks for the StackHorizontal function, it works really good. However, the edge transition is still pretty abrupt. How can I "smooth" that boundary?
Also, how can I use Tweak on an image with dimensions like 7x8 (it says I cant use RGB data)? Do I need to make a fake extra 1 pixel line and crop it off again...?

Also, I updated the image link.

Last edited by AviUser; 24th August 2010 at 23:52.
AviUser is offline   Reply With Quote
Old 24th August 2010, 23:58   #5  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
I can answer the tweak question . It only works on YUV data . So you would have to ConvertToYV12() or ConvertToYUY2() first , and if your source is interlaced (it might from your posted image, not sure), don't forget interlaced=true .

And IIRC correctly, you cannot freely crop interlaced YV12 material , it has to be in multiples of 4 (I think) .

Are you doing this for actual video or on still images ?

Last edited by poisondeathray; 25th August 2010 at 00:07.
poisondeathray is offline   Reply With Quote
Old 25th August 2010, 00:17   #6  |  Link
AviUser
Registered User
 
Join Date: Mar 2009
Posts: 39
Thanks. Actual video.

Both of us have the same question now about feathered overlay I guess.
AviUser is offline   Reply With Quote
Old 25th August 2010, 00:19   #7  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
But is your video interlaced, and what colorspace ?
poisondeathray is offline   Reply With Quote
Old 25th August 2010, 00:41   #8  |  Link
AviUser
Registered User
 
Join Date: Mar 2009
Posts: 39
The video is already deinterlaced before I attempt to darken the line and it is in YV12 color space.
Should I deinterlace after darkening the line?
AviUser is offline   Reply With Quote
Old 25th August 2010, 09:01   #9  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
For feathered edge transitions, Overlay() or Layer() with an appropriate mask is the way forward.

If maximum efficiency is the goal, then the hard slice and stack option can be used to reduce the size of the image actually being processed.

e.g.
Code:
...
Left=Crop(0,0 40,0)
Cent=Crop(40,0, -40,0)
Right=Crop(Width()-40,0, 0,0)

FixLeft=Left.Filter(...) # process as required
MaskLeft=ImageSource("MaskLeft.ebmp", End=0).Loop(FrameCount()) # White=Opaque, use FixLeft pixels
Left=Left.Overlay(FixLeft, Mask=MaskLeft) # Feathered blend at boundary according to mask

FixRight=Right.Filter(...) # process as required
MaskRight=ImageSource("MaskRight.ebmp", End=0).Loop(FrameCount()) # White=Opaque, use FixRight pixels
Right=Right.Overlay(FixLeft, Mask=MaskRight) # Feathered blend at boundary according to mask

StackHorizontal(Left, Cent, Right)
If it mattered, the heavy lifting is only done on 2 by 40 pixel wide strips. The main centre pixels remain unprocessed and fast. Unless Filter(...) is heavy duty and I suspect it will just be a Tweak() or such, this is really just a thought exercise. Tweak or Overlay() are not really that heavy duty.
IanB is offline   Reply With Quote
Old 25th August 2010, 17:41   #10  |  Link
AviUser
Registered User
 
Join Date: Mar 2009
Posts: 39
Thanks, I ended up using "the hard slice and stack option" and Tweaking the line to be less bright. I also Blur()ed the edge again using the slicing option.

It looks kind of strange but its better than before.

Thanks all for your replies!
AviUser is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:41.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.