Roelof - here's an example
load 'images'
arbimage=. <.20*+/~2 o. i:3j999 NB. Arbitrary image: 1000x1000
(<./,>./),arbimage NB. Integers from _40 to 39
_40 39
arbimage{~,&.>~495+i.5 5 NB. High values in center
39 39 39 39 39
39 39 39 39 39
39 39 39 39 39
39 39 39 39 39
39 39 39 39 39
5 5{.arbimage NB. Low values in corners
_40 _40 _40 _40 _40
_40 _40 _40 _40 _40
_40 _40 _40 _40 _40
_40 _40 _40 _40 _40
_40 _40 _40 _40 _40
makeGrayPal=: [: |: 3 # [: ,: [: <. 0.5 + i. * 255 % <:
NB.* makeGrayPal: make gray-scale palette with y entries.
$pal100=. makeGrayPal 100
100 3
(3&{.,_3&{.) pal100 NB. palette ranges from black to white
0 0 0
3 3 3
5 5 5
250 250 250
252 252 252
255 255 255
NB. Write an image file using the palette.
(pal100{~arbimage-<./,arbimage) write_image 'C:\temp\pseudoDensity.png'
73624
NB. ".png" is efficient format for generated images; figures type from
suffix:
(pal100{~arbimage-<./,arbimage) write_image 'C:\temp\pseudoDensity.jpg'
191578
NB. ".jpg" takes 191K, ".png" only 74K.
NB. File will look like this:
(79{.pal100) viewmat arbimage
NB. where we use "79" because
(>./-<./),arbimage
79
On Mon, Dec 15, 2008 at 8:49 AM, Roelof K Brouwer <[email protected]>wrote:
> You are right in that most of the time when I start to expand the window I
> will get the right image. However sometimes even with that action I get
> the
> wrong image ( vague , hazy lines as opposed to squares. Also in ijx with
> debug on which I used to stop my verb before the savemat action I get the
> same result in the ijx window.
> My images are simply like density plots and I will look at image3 addon. Is
> it a matter of replacing 2 lines with 2 lines in my verb or something much
> more complex ( nothing to do with complex numbers) than that.
>
> cheers
>
>
> Roelof
>
> "Have a cool mind and a warm heart" - Ajahn Sona
> "Like ......(hamsters on a wheel), (ambitious people) still climb and
> climb, with great labor, and incessant anxiety, but never reach the top."
> Robert Browning
> "We shall not cease from exploration. And at the end of all our exploring
> Will be to arrive were we started and know the place for the first time" -
> T. S. Eliot
>
>
> Dr. Roelof K. Brouwer PH.D. P.Eng.
> Professor Emeritus
> Dept. of Computing Science
> School of Advanced Technologies and Mathematics
> Thompson Rivers University
> 900 McGill Road
> Kamloops, BC
> Canada, V2C 5N3
>
> email : [email protected]
> www.tru.ca/advtech/compsci/faculty/rbrouwer
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Devon McCormick
> Sent: December-14-08 9:32 PM
> To: Programming forum
> Subject: Re: [Jprogramming] savemat_jviewmat_
>
> Dr. Brouwer - I think this is not so much a Vista 64-bit problem but a
> general problem with the event-loop/message-pump handling.
>
> I've encountered this problem before: I have a sequence of lines of code
> that work fine in immediate execution but fail when they're in a function.
> I believe the problem is that viewmat needs to get to a state of waiting
> for
> user input before it will finish displaying its picture. This doesn't
> happen within multiple lines in a function, so only a blank picture is
> saved.
>
> I've tried lots of different ways to get around this and have settled on
> using the "image3" add-on to write my images instead of relying on viewmat.
> This is too bad because viewmat does offer a nice display of complex
> numbers
> that I haven't replicated with image3 code.
>
> This problem is also mentioned by Dan Bron at
> http://www.jsoftware.com/jwiki/DanBron/Snippets/PrettyPictures and even
> Oleg
> doesn't have a solution.
>
> Regards,
>
> Devon**
>
> On Sun, Dec 14, 2008 at 12:54 PM, Roelof K Brouwer
> <[email protected]>wrote:
>
> > I have problems with viewmat save in vista 64bit. In particular the
> > following two statements
> >
> >
> >
> >
> >
> > ( 1 4 14 {". COLOR16) viewmat i.4 4
> >
> > savemat_jviewmat_ 'C:\Temp\garbage.bmp'
> >
> >
> >
> >
> >
> > this will give a blank window when used in a verb
> >
> > and also in ijx when debug is in
> >
> > sometimes by adjusting the viewmat window I will get the proper display .
> > i.e. click the margin of the window for exdpansion. However sometimes on
> > expansion the window does not have the correct
> >
> > displayI
> >
> > if I remove the save command things will work
> >
> >
> >
> > when in ijx I can first run viewmat command and then the save command and
> > things will work
> >
> > I also tried puttting a delay between the two viewmat commands
> >
> >
> >
> > here is my complete file with verb
> >
> >
> >
> > drivedata=: 'C:\Users\RKBrouwer\Documents\ACA\Research\ResData\'
> >
> > drive_op=:'C:\Users\RKBrouwer\Documents\Temp\Set\'
> >
> > drive=:'C:\Users\RKBrouwer\Documents\ACA\'
> >
> > require 'viewmat color16 plot'
> >
> > load 'C:\Users\RKBrouwer\Documents\J_Code_Roelof\J_utilities_roelof.ijs'
> >
> > NB. load
> > 'C:\Users\RKBrouwer\Documents\J_utilities_roelof\visual_clustering.ijs'
> >
> > require 'jfiles'
> >
> >
> >
> > test_viewmat=:3 : 0
> >
> > ( 1 4 14 {". COLOR16) viewmat i.4 4
> >
> > savemat_jviewmat_ 'C:\Temp\garbage.bmp'
> >
> > )
> >
> >
> >
> >
> >
> >
> >
> > cheers
> >
> >
> >
> >
> >
> > Roelof
> >
> >
> >
> > "Have a cool mind and a warm heart" - Ajahn Sona
> >
> > "Like ......(hamsters on a wheel), (ambitious people) still climb and
> > climb, with great labor, and incessant anxiety, but never reach the top."
> > Robert Browning
> >
> > "We shall not cease from exploration. And at the end of all our exploring
> >
> > Will be to arrive were we started and know the place for the first time"
> -
> > T. S. Eliot
> >
> >
> >
> >
> >
> > Dr. Roelof K. Brouwer PH.D. P.Eng.
> >
> > Professor Emeritus
> >
> > Dept. of Computing Science
> >
> > School of Advanced Technologies and Mathematics
> >
> > Thompson Rivers University
> >
> > 900 McGill Road
> >
> > Kamloops, BC
> >
> > Canada, V2C 5N3
> >
> >
> >
> > email : <mailto:[email protected]> [email protected]
> >
> > <http://www.tru.ca/advtech/compsci/faculty/rbrouwer>
> > www.tru.ca/advtech/compsci/faculty/rbrouwer
> >
> >
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
>
>
> --
> Devon McCormick, CFA
> ^me^ at acm.
> org is my
> preferred e-mail
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm