Quantcast

Colour Manipulation

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Colour Manipulation

Bob Sneidar via use-livecode
I've got an app that allows the user to display an image using a variable number of colours (2-24 colours).  In addition, the user can specify upper and lower thresholds so that all pixels below a specified value are displayed using a colour such as black and all pixels with values above a specified value are displayed using a colour such as red.  Pixels with values between the thresholds are displayed using the specified colour range of 2-24 colours. The images can consist of up to 8-10 million pixels, they are rectangular and can be in a landscape or portrait orientation.

Whilst I have this working the code that manages the changing of the number and use of colours in an image is rather slow.  This is despite me using the "repeat for each" loop structure and lock the screen wherever possible to get the maximum speed!

Does anyone have any clever algorithms, code, add-ons, etc. that can do this kind of thing in a flash?!

Thanks

Peter
--
Peter Reid
Loughborough, UK


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Colour Manipulation

Bob Sneidar via use-livecode
With 10 million pixels, comparing 3 different base colors (RGB), and checking both upper and lower bounds, that comes to 60 million comparisons. That is an awful lot for a scripted environment.

You would need to make an external (and, frankly, the LC instructions on making desktop externals do not work for modern versions of LC and Visual Studio).

For a project, I was able to successfully use ImageMagick as a command line image processor. It took a few seconds, but much better than what LC took.

ImageMagick is pretty flexible and might give you what you need. I was using it for green screen image extractions.

Sent from my iPhone

> On Mar 18, 2017, at 2:20 PM, Peter Reid via use-livecode <[hidden email]> wrote:
>
> I've got an app that allows the user to display an image using a variable number of colours (2-24 colours).  In addition, the user can specify upper and lower thresholds so that all pixels below a specified value are displayed using a colour such as black and all pixels with values above a specified value are displayed using a colour such as red.  Pixels with values between the thresholds are displayed using the specified colour range of 2-24 colours. The images can consist of up to 8-10 million pixels, they are rectangular and can be in a landscape or portrait orientation.
>
> Whilst I have this working the code that manages the changing of the number and use of colours in an image is rather slow.  This is despite me using the "repeat for each" loop structure and lock the screen wherever possible to get the maximum speed!
>
> Does anyone have any clever algorithms, code, add-ons, etc. that can do this kind of thing in a flash?!
>
> Thanks
>
> Peter
> --
> Peter Reid
> Loughborough, UK
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Colour Manipulation

Bob Sneidar via use-livecode
You could put the entire ImageMagick set of files into custom properties, then, when your app first opens, look to see if ImageMagick is present. If not, then have your app save the ImageMagick files in the same folder as your app.

I have done that sort of thing before -  big files, but works fine.

If you can find a Javascipt library that does what you need, your mission would be easy :)

Sent from my iPhone

> On Mar 18, 2017, at 5:03 PM, [hidden email] wrote:
>
> With 10 million pixels, comparing 3 different base colors (RGB), and checking both upper and lower bounds, that comes to 60 million comparisons. That is an awful lot for a scripted environment.
>
> You would need to make an external (and, frankly, the LC instructions on making desktop externals do not work for modern versions of LC and Visual Studio).
>
> For a project, I was able to successfully use ImageMagick as a command line image processor. It took a few seconds, but much better than what LC took.
>
> ImageMagick is pretty flexible and might give you what you need. I was using it for green screen image extractions.
>
> Sent from my iPhone
>
>> On Mar 18, 2017, at 2:20 PM, Peter Reid via use-livecode <[hidden email]> wrote:
>>
>> I've got an app that allows the user to display an image using a variable number of colours (2-24 colours).  In addition, the user can specify upper and lower thresholds so that all pixels below a specified value are displayed using a colour such as black and all pixels with values above a specified value are displayed using a colour such as red.  Pixels with values between the thresholds are displayed using the specified colour range of 2-24 colours. The images can consist of up to 8-10 million pixels, they are rectangular and can be in a landscape or portrait orientation.
>>
>> Whilst I have this working the code that manages the changing of the number and use of colours in an image is rather slow.  This is despite me using the "repeat for each" loop structure and lock the screen wherever possible to get the maximum speed!
>>
>> Does anyone have any clever algorithms, code, add-ons, etc. that can do this kind of thing in a flash?!
>>
>> Thanks
>>
>> Peter
>> --
>> Peter Reid
>> Loughborough, UK
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Colour Manipulation

Bob Sneidar via use-livecode
You could write a small app just to do the processing (or use a web server
with an lc script to process) break it into chunks, and spawn
processes/server requests to offload the work maybe. Though imagemagick
would be a pretty awesome solution if it can be made to do what you need.

On Sat, Mar 18, 2017 at 4:02 PM, Jonathan Lynch via use-livecode <
[hidden email]> wrote:

> You could put the entire ImageMagick set of files into custom properties,
> then, when your app first opens, look to see if ImageMagick is present. If
> not, then have your app save the ImageMagick files in the same folder as
> your app.
>
> I have done that sort of thing before -  big files, but works fine.
>
> If you can find a Javascipt library that does what you need, your mission
> would be easy :)
>
> Sent from my iPhone
>
> > On Mar 18, 2017, at 5:03 PM, [hidden email] wrote:
> >
> > With 10 million pixels, comparing 3 different base colors (RGB), and
> checking both upper and lower bounds, that comes to 60 million comparisons.
> That is an awful lot for a scripted environment.
> >
> > You would need to make an external (and, frankly, the LC instructions on
> making desktop externals do not work for modern versions of LC and Visual
> Studio).
> >
> > For a project, I was able to successfully use ImageMagick as a command
> line image processor. It took a few seconds, but much better than what LC
> took.
> >
> > ImageMagick is pretty flexible and might give you what you need. I was
> using it for green screen image extractions.
> >
> > Sent from my iPhone
> >
> >> On Mar 18, 2017, at 2:20 PM, Peter Reid via use-livecode <
> [hidden email]> wrote:
> >>
> >> I've got an app that allows the user to display an image using a
> variable number of colours (2-24 colours).  In addition, the user can
> specify upper and lower thresholds so that all pixels below a specified
> value are displayed using a colour such as black and all pixels with values
> above a specified value are displayed using a colour such as red.  Pixels
> with values between the thresholds are displayed using the specified colour
> range of 2-24 colours. The images can consist of up to 8-10 million pixels,
> they are rectangular and can be in a landscape or portrait orientation.
> >>
> >> Whilst I have this working the code that manages the changing of the
> number and use of colours in an image is rather slow.  This is despite me
> using the "repeat for each" loop structure and lock the screen wherever
> possible to get the maximum speed!
> >>
> >> Does anyone have any clever algorithms, code, add-ons, etc. that can do
> this kind of thing in a flash?!
> >>
> >> Thanks
> >>
> >> Peter
> >> --
> >> Peter Reid
> >> Loughborough, UK
> >>
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> [hidden email]
> >> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Colour Manipulation

Bob Sneidar via use-livecode
It would be amazing if the LC folks created an ImageMagick wrapper so that we could use it as an external or widget!

Sent from my iPhone

> On Mar 18, 2017, at 11:30 PM, Mike Bonner via use-livecode <[hidden email]> wrote:
>
> You could write a small app just to do the processing (or use a web server
> with an lc script to process) break it into chunks, and spawn
> processes/server requests to offload the work maybe. Though imagemagick
> would be a pretty awesome solution if it can be made to do what you need.
>
> On Sat, Mar 18, 2017 at 4:02 PM, Jonathan Lynch via use-livecode <
> [hidden email]> wrote:
>
>> You could put the entire ImageMagick set of files into custom properties,
>> then, when your app first opens, look to see if ImageMagick is present. If
>> not, then have your app save the ImageMagick files in the same folder as
>> your app.
>>
>> I have done that sort of thing before -  big files, but works fine.
>>
>> If you can find a Javascipt library that does what you need, your mission
>> would be easy :)
>>
>> Sent from my iPhone
>>
>>> On Mar 18, 2017, at 5:03 PM, [hidden email] wrote:
>>>
>>> With 10 million pixels, comparing 3 different base colors (RGB), and
>> checking both upper and lower bounds, that comes to 60 million comparisons.
>> That is an awful lot for a scripted environment.
>>>
>>> You would need to make an external (and, frankly, the LC instructions on
>> making desktop externals do not work for modern versions of LC and Visual
>> Studio).
>>>
>>> For a project, I was able to successfully use ImageMagick as a command
>> line image processor. It took a few seconds, but much better than what LC
>> took.
>>>
>>> ImageMagick is pretty flexible and might give you what you need. I was
>> using it for green screen image extractions.
>>>
>>> Sent from my iPhone
>>>
>>>> On Mar 18, 2017, at 2:20 PM, Peter Reid via use-livecode <
>> [hidden email]> wrote:
>>>>
>>>> I've got an app that allows the user to display an image using a
>> variable number of colours (2-24 colours).  In addition, the user can
>> specify upper and lower thresholds so that all pixels below a specified
>> value are displayed using a colour such as black and all pixels with values
>> above a specified value are displayed using a colour such as red.  Pixels
>> with values between the thresholds are displayed using the specified colour
>> range of 2-24 colours. The images can consist of up to 8-10 million pixels,
>> they are rectangular and can be in a landscape or portrait orientation.
>>>>
>>>> Whilst I have this working the code that manages the changing of the
>> number and use of colours in an image is rather slow.  This is despite me
>> using the "repeat for each" loop structure and lock the screen wherever
>> possible to get the maximum speed!
>>>>
>>>> Does anyone have any clever algorithms, code, add-ons, etc. that can do
>> this kind of thing in a flash?!
>>>>
>>>> Thanks
>>>>
>>>> Peter
>>>> --
>>>> Peter Reid
>>>> Loughborough, UK
>>>>
>>>>
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Colour Manipulation

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
> Jonathan L. wrote:
> It would be amazing if the LC folks created an ImageMagick wrapper so that
> we could use it as an external or widget!

There is a Java interface (JMagick, see https://www.imagemagick.org/script/api.php)
and the brand-new LiveCode FFI for Java.

> If you can find a Javascript library that does what you need, your mission
> would be easy :)

You can handle imagedata in HTML5/canvas2D very similar to LiveCode or use webGL.
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Colour Manipulation

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
Yes I agree wholeheartedly with Johnathan -

I once (maybe five years ago) wanted to use ImageMagick but was put off, partly because I wanted to put it into a commercial product and couldn’t understanding the licensing rules: in particular, it seemed that I had to give all my users (purchasers) access to IM somehow, including the source code… I could never understand how to do this cleanly. That, and the (to me) astonishingly hard to use interface, coupled with zero support, made me think the whole thing was a non-starter. I wonder what people think now. By “people” I mean those of us who really don’t want to step at all far out of the LiveCode comfort zone, even to do a bit of command-line tweaking. Oh, and want their solutions cross-platform.

Graham

> On 19 Mar 2017, at 04:48, Jonathan Lynch via use-livecode <[hidden email]> wrote:
>
> It would be amazing if the LC folks created an ImageMagick wrapper so that we could use it as an external or widget!
>
> Sent from my iPhone
>
>> On Mar 18, 2017, at 11:30 PM, Mike Bonner via use-livecode <[hidden email]> wrote:
>>
>> You could write a small app just to do the processing (or use a web server
>> with an lc script to process) break it into chunks, and spawn
>> processes/server requests to offload the work maybe. Though imagemagick
>> would be a pretty awesome solution if it can be made to do what you need.
>>
>> On Sat, Mar 18, 2017 at 4:02 PM, Jonathan Lynch via use-livecode <
>> [hidden email]> wrote:
>>
>>> You could put the entire ImageMagick set of files into custom properties,
>>> then, when your app first opens, look to see if ImageMagick is present. If
>>> not, then have your app save the ImageMagick files in the same folder as
>>> your app.
>>>
>>> I have done that sort of thing before -  big files, but works fine.
>>>
>>> If you can find a Javascipt library that does what you need, your mission
>>> would be easy :)
>>>
>>> Sent from my iPhone
>>>
>>>> On Mar 18, 2017, at 5:03 PM, [hidden email] wrote:
>>>>
>>>> With 10 million pixels, comparing 3 different base colors (RGB), and
>>> checking both upper and lower bounds, that comes to 60 million comparisons.
>>> That is an awful lot for a scripted environment.
>>>>
>>>> You would need to make an external (and, frankly, the LC instructions on
>>> making desktop externals do not work for modern versions of LC and Visual
>>> Studio).
>>>>
>>>> For a project, I was able to successfully use ImageMagick as a command
>>> line image processor. It took a few seconds, but much better than what LC
>>> took.
>>>>
>>>> ImageMagick is pretty flexible and might give you what you need. I was
>>> using it for green screen image extractions.
>>>>
>>>> Sent from my iPhone
>>>>
>>>>> On Mar 18, 2017, at 2:20 PM, Peter Reid via use-livecode <
>>> [hidden email]> wrote:
>>>>>
>>>>> I've got an app that allows the user to display an image using a
>>> variable number of colours (2-24 colours).  In addition, the user can
>>> specify upper and lower thresholds so that all pixels below a specified
>>> value are displayed using a colour such as black and all pixels with values
>>> above a specified value are displayed using a colour such as red.  Pixels
>>> with values between the thresholds are displayed using the specified colour
>>> range of 2-24 colours. The images can consist of up to 8-10 million pixels,
>>> they are rectangular and can be in a landscape or portrait orientation.
>>>>>
>>>>> Whilst I have this working the code that manages the changing of the
>>> number and use of colours in an image is rather slow.  This is despite me
>>> using the "repeat for each" loop structure and lock the screen wherever
>>> possible to get the maximum speed!
>>>>>
>>>>> Does anyone have any clever algorithms, code, add-ons, etc. that can do
>>> this kind of thing in a flash?!
>>>>>
>>>>> Thanks
>>>>>
>>>>> Peter
>>>>> --
>>>>> Peter Reid
>>>>> Loughborough, UK
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> [hidden email]
>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Loading...