deleting every other line in an image

BNig niggemann at uni-wh.de
Mon Nov 12 18:34:07 EST 2007


Hi Josh,

make a stack with 2 images, call them "P1" and "P2"
load a picture in the inspector into image "p1"
set the width and height to 140 in the inspector

make a new button

paste this script into the button

on mouseUp
    put the width of image "P1" into theImagWidth
    put the height of image "P1" into theImageHeight
    put the imagedata of image "P1" into theDataToWorkon
    if theDataToWorkon = "" then exit mouseUp
    put length (theDataToWorkon) into HowLong
    put empty into destImageData
    
    -- one Pixel = 4 Bytes = 4 chars
    put theImagWidth * 4 into OneRowOfImage
    put theImageHeight into soManyPixelRows
    
    put 0 into theCounter
    repeat   with i = 1 to (HowLong - OneRowOfImage) step (OneRowOfImage*2)
        put  char i to (i + OneRowOfImage-1) of theDataToWorkon  after
destImageData
    end repeat
    
    set the width of image "P2" to theImagWidth
    -- watch out for images with uneven heigths
    set the height of image "P2" to (theImageHeight/2)
    set the imagedata of image "P2" to destImageData
end mouseUp

this should give you in "P2" an image half the height of P1 with every
second line of the original image.

it works for me, attention, almost no error checking in here, 
it is important to have the width and height correct otherwise the image
will be distorted

just curious: why do you want to eliminate every second line of an image?

hth

Bernd



Josh Mellicker wrote:
> 
> Here's one for the image processing gurus out there:
> 
> How difficult is it to take an image, and create a new image  
> containing every OTHER line from it (e.g., just the odd lines) so the  
> resulting picture is half the height?
> 
> Once you knew the width of the image, isn't it just a loop that  
> copies tWidth pixels, then skips the next tWidth, and so on?
> 
> Thanks!
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> 

-- 
View this message in context: http://www.nabble.com/deleting-every-other-line-in-an-image-tf4793676.html#a13716667
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list