This works for me:
load '~addons\media\image3\view_m.ijs'
view_image BW256;p=:512#,:2#i.256
512 512
85 0 1 (,:"0 p) write_jpeg fn=:'c:\temp\test_image.jpg'
7578
view_image fn
512 512
Does this give you a starting point? Ask with a more specific
example of the problem if not.
Best,
Cliff
[EMAIL PROTECTED] wrote:
Hello everyone, this is my first product/experience in J and I have really
enjoyed it thus far. I am running into a roadblock that I just can't seem to
figure out.
I have the Image3 addon and with it I have converted some of my own JPEG images into a 400x600x1 grayscale image then down to a 400x600 matrix to do some filtering and matrix manipulations. I am able to get the final product back into a 400x600x1 grayscale array I suppose and I can view it using view_data but I just can't seem to save it as a JPEG properly.
So let's say I have my 400x600x1 grayscale data called FINAL . Below is
script I found in the Image3 addon help section, and I believe this is what I
need to use but I just can't seem to incorporate it properly. Can anyone give
me a hand?
I have been trying things like
FINAL mem_to_jpeg ('testimage.jpg', ???, ???)
and
[100] FINAL write_jpeg 'testimage.jpg'
I'm lost, here is the Script:
NB. data mem_to_jpeg (file_name; JPEG_RGB; qaulity_default)
NB. [jpeg_quality] data write_jpeg filename
NB. data may be raw or integer matrices of
NB. rgb-triples (color) or single items (grayscale)
write_jpeg=: 1 : 0
(jpeg_quality,progressive,gray_scaling) m write_jpeg y
:
'jq pr gs'=.x,(#x)}.jpeg_quality,progressive,gray_scaling
if. 32=(3!:0) m do. m=.{~&>/m end.
if. 2 = $$m do. m=.,"0 m end. NB. make rank 3
if. 4=(3!:0) m do. m=.m{a. end. NB. make it raw
select. gs
case. _1 do. if. 1={:$m do. m=.3#"1 m end.
case. 0 do. ''
case. 1 do. if. 3={:$m do. m=.,@<.@(+/%#)"1&.(a.&i.) m end.
case. 2 do. if. 3={:$m do.
if. (-:1&|."1)m do. m=.,@{."1 m end. end.
end.
if. -. 1 3 e.~ {:$m do. 'unsupported 3rd axis length' return. end.
sz=. */$m
addr=.mema sz
(,m) memw addr,0,sz
a=.>{.'mem_to_jpeg + i *c i i i i i i' zjm (y;addr),(;/ 1 0 2 {$m),(jq;pr)
memf addr
if. _1=a do. 'error writing inside dll...' return. end.
fsize y
)
Thank you!
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
Clifford A. Reiter
Mathematics Department, Lafayette College
Easton, PA 18042 USA, 610-330-5277
http://www.lafayette.edu/~reiterc
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm