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. |
24th August 2010, 20:24 | #1 | Link |
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 |
24th August 2010, 23:08 | #2 | Link |
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) 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. |
24th August 2010, 23:37 | #3 | Link |
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...) |
24th August 2010, 23:47 | #4 | Link |
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. |
24th August 2010, 23:58 | #5 | Link |
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. |
25th August 2010, 09:01 | #9 | Link |
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) |
25th August 2010, 17:41 | #10 | Link |
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! |
|
|