ImagePro>Re: File-Export and File-Import of a float picture
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ImagePro>Re: File-Export and File-Import of a float picture
- To: "Image-Pro Users List" <imagepro-users[at]lists.mediacy.com>
- Subject: ImagePro>Re: File-Export and File-Import of a float picture
- From: Christian Hof <Christian.Hof[at]bmw.de>
- Date: Fri, 07 May 2004 10:35:39 +0200
- List-Archive: <http://lists.mediacy.com:80/Lists/imagepro-users/List.html>
- List-ID: <imagepro-users.lists.mediacy.com>
- List-Unsubscribe: <mailto:imagepro-users-off@lists.mediacy.com>
- Reply-To: "Image-Pro Users List" <imagepro-users[at]lists.mediacy.com>
- Sender: "Image-Pro Users List" <imagepro-users[at]lists.mediacy.com>
That's it!
Such a beginner's mistake!
Thanks this was very helpful for me!
Regards
Christian
yuri@mediacy.com schrieb:
>
> Hi Christian,
>
> From a brief look at your code I noticed that imbuf in ReadAsciiFile is
> allocated as Double (64-bit), where IMC_FLOAT image type uses Single
> (32-bit). It can explain the second column.
>
> Changing Double to Single should solve the problem.
>
> Regards,
>
> Yuri Gaidoukevitch
> Media Cybernetics
>
> > -----Original Message-----
> > From: Image-Pro Users List [mailto:imagepro-users@lists.mediacy.com] On
> > Behalf Of Christian Hof
> > Sent: Friday, May 07, 2004 9:47 AM
> > To: Image-Pro Users List
> > Subject: ImagePro>File-Export and File-Import of a float picture
> >
> > Hello you all,
> >
> > I'm a new ImagePro user.
> > I' ve got some problems with the Macros which were suggested some times
> > before. I want to export a Float-Image to a file and later I want to
> > import it back into ImagePro so I have changed some code of the Macro
> > because it was for a Gray Picture.
> >
> > The export Macro saves the data in a file but when I try to import the
> > same file every second column is not correct. It has the value 2 so the
> > image has stripes.
> >
> > I post the modified macros with this Mail in the hope for that someone
> > can tell me where there is the mistake.
> >
> > Here are the Code:
> >
> > '_____Write to Ascii_________________________________________________
> > Option Explicit
> >
> > Sub WriteAsciiFile()
> > Dim row As Integer
> > Dim col As Integer
> > Dim imrect As RECT
> > Dim dinfo As IPDOCINFO 'struct IPDOCINFO
> > Dim delimiter$, filename As String * 255
> >
> > ' Each line in the image is saved as a line in the file.
> > ' Pixel values are separated by: (un-comment the appropriate one)
> > delimiter = Chr$(9) ' a tab
> > 'delimiter = "," ' a comma
> > 'delimiter = " " ' one space
> >
> > ' get the active image size. exit if no active image
> > ret = IpDocGet(GETDOCINFO, DOCSEL_ACTIVE, dinfo) ' Holt Information
> > eines Documents ab
> > If ret < 0 Then Exit Sub
> > ' prompt user for file name
> > ret = IpStGetName("Save file?", "c:\", "*.bit", filename)
> > If ret = 0 Then Exit Sub
> > ' open file
> > On Error GoTo fileopen
> > Open filename For Output As #1
> > ' put image data into array
> > ReDim imbuf(1 To dinfo.Width, 1 To dinfo.Height) As Double
> > 'ß----------------------------Changed from nteger to Double
> > imrect.Left = 0
> > imrect.top = 0
> > imrect.Right = dinfo.Width - 1
> > imrect.bottom = dinfo.Height - 1
> > ret = IpDocGetArea(DOCSEL_ACTIVE, imrect, imbuf(1,1),0)
> > 'ß------------------maybe CPROG----------------------------------
> > ' write image to file pixel by pixel
> > ret = IpTrackBar(TBOPEN, dinfo.height, "Writing To ASCII File")
> > For row = 1 To dinfo.height
> > If IpTrackBar(TBUPDATE, row -1, "") <> 0 Then GoTo userabort10
> > For col = 1 To dinfo.width -1
> > Print #1,Format$(imbuf(col, row)) +
> > delimiter;
> > 'ß----------------------Possible to Format$(2.145,"Standard")
> > Next col
> > Print #1,Format$(imbuf(dinfo.width, row))
> > 'ß----------------------Possible to Format$(2.145,"Standard")
> > Next row
> > userabort10:
> > ret = IpTrackBar(TBCLOSE, 0, "")
> > Close #1
> > Exit Sub
> > fileopen:
> > MsgBox "Error creating image text file: " + Err
> > End Sub
> >
> >
> >
> > '______Read from
> > Ascii_________________________________________________________
> > Option Explicit
> >
> > Sub ReadAsciiFile()
> > Dim row%, col%, docid%
> > Dim numrows%, numcols%
> > Dim imrect As rect
> > Dim linebuf$
> > Dim curpos%, nextpos%
> > Dim delimiter$, filename As String * 255
> >
> > ' Each line in the file corresponds to a line in the image.
> > ' Pixel values are separated by: (un-comment the appropriate one)
> > delimiter = Chr$(9) ' a tab
> > 'delimiter = "," ' a comma
> > 'delimiter = " " ' one space
> >
> > ' prompt user for file name
> > ret = IpStGetName("Open file?", "c:\", "*.bit", filename)
> >
> >
> > If ret = 0 Then Exit Sub
> > ' open file
> > On Error GoTo fileopen
> > Open filename For Input As #1
> >
> > ' ask user for the image dimensions
> > ret = IpStGetInt("Number of pixels/line [0-1000]?", numcols, 324, 1,
> > 1000)
> > ret = IpStGetInt("Number of lines [0-1000]?", numrows, 124, 1, 1000)
> > ' create empty image window
> > docid = IpWsCreate(numcols, numrows, 75,
> > IMC_Float)'&--------------------changed to
> > IMC_Float-----------------------------
> > ' allocate array receiving the file data
> > ReDim imbuf(1 To numcols, 1 To numrows) As Double '&-----changed to
> > Double------------------------------------------------
> > ' read file line by line, pixel by pixel
> > ret = IpTrackBar(TBOPEN, numrows, "Reading from ASCII file")
> > On Error GoTo fileread
> > For row = 1 To numrows
> > If IpTrackBar(TBUPDATE, row -1, "") <> 0 Then GoTo finish_up 'Anzeige
> > unten
> > Line Input #1, linebuf
> > curpos = 1
> > For col = 1 To numcols - 1
> > ' look for the next delimiter
> > nextpos = InStr(curpos, linebuf, delimiter)'Return the index where
> > delemiter first matches in linebuf. If no match is found return 0.
> >
> > imbuf(col, row) = CSng(Mid$(linebuf, curpos, nextpos - curpos))
> > 'Val(Mid$(linebuf, curpos, nextpos - curpos)) 'ß-----------------CSNG
> > curpos = nextpos + 1 'Counter
> > Next col
> > imbuf(col, row) = CSNG(Mid$(linebuf, curpos)) 'ß---------Changed from
> > VAL to CSNG-----------------------
> > Next row
> >
> > GoTo finish_up
> > fileread:
> > MsgBox "Error reading file: " + Err
> > finish_up:
> > imrect.Left = 0
> > imrect.top = 0
> > imrect.Right = numcols - 1
> > imrect.bottom = numrows - 1
> >
> > ret = IpDocPutArea(docid, imrect, imbuf(1,1), 0)
> > ret = IpTrackBar(TBCLOSE, 0, "")
> > Close #1
> > ret = IpAppUpdateDoc(docid)
> > Exit Sub
> > fileopen:
> > MsgBox "Error opening image file: " + Err
> > Exit Sub
> > End Sub
> >
> >
> > Thanks a lot
> >
> > Regards,
> >
> > Christian Hof
> > mailto: Christian.Hof@bmw.de
> >
> > ***********************************************************
> > This message was sent to you because you are subscribed to <imagepro-
> > users@lists.mediacy.com>.
> > TO UNSUBSCRIBE, send an email to: <imagepro-users-off@lists.mediacy.com>
> > To switch to the DIGEST mode, email to <imagepro-users-
> > digest@lists.mediacy.com>
> > To switch to the INDEX mode, email to <imagepro-users-
> > index@lists.mediacy.com>
> > Send administrative queries to <imagepro-users-request@lists.mediacy.com>
> > To SUBSCRIBE or UNSUBSCRIBE visit
> > http://www.mediacy.com/tech/subscriber.htm
> > ***********************************************************
> > This list is a forum for sharing applications, advice, and tips involving
> > Media Cybernetics' products. It is not meant to be used as a vehicle for
> > techncial support or for sales of third party products or services.
> > ***********************************************************
> > Need an Image-Pro macro or driver? Find it at http://www.Solutions-
> > Zone.com
> > Got an Image-Pro macro or driver? Add it to http://www.Solutions-Zone.com
> > ***********************************************************
>
> ***********************************************************
> This message was sent to you because you are subscribed to <imagepro-users@lists.mediacy.com>.
> TO UNSUBSCRIBE, send an email to: <imagepro-users-off@lists.mediacy.com>
> To switch to the DIGEST mode, email to <imagepro-users-digest@lists.mediacy.com>
> To switch to the INDEX mode, email to <imagepro-users-index@lists.mediacy.com>
> Send administrative queries to <imagepro-users-request@lists.mediacy.com>
> To SUBSCRIBE or UNSUBSCRIBE visit http://www.mediacy.com/tech/subscriber.htm
> ***********************************************************
> This list is a forum for sharing applications, advice, and tips involving Media Cybernetics' products. It is not meant to be used as a vehicle for techncial support or for sales of third party products or services.
> ***********************************************************
> Need an Image-Pro macro or driver? Find it at http://www.Solutions-Zone.com
> Got an Image-Pro macro or driver? Add it to http://www.Solutions-Zone.com
> ***********************************************************
***********************************************************
This message was sent to you because you are subscribed to <imagepro-users@lists.mediacy.com>.
TO UNSUBSCRIBE, send an email to: <imagepro-users-off@lists.mediacy.com>
To switch to the DIGEST mode, email to <imagepro-users-digest@lists.mediacy.com>
To switch to the INDEX mode, email to <imagepro-users-index@lists.mediacy.com>
Send administrative queries to <imagepro-users-request@lists.mediacy.com>
To SUBSCRIBE or UNSUBSCRIBE visit http://www.mediacy.com/tech/subscriber.htm
***********************************************************
This list is a forum for sharing applications, advice, and tips involving Media Cybernetics' products. It is not meant to be used as a vehicle for techncial support or for sales of third party products or services.
***********************************************************
Need an Image-Pro macro or driver? Find it at http://www.Solutions-Zone.com
Got an Image-Pro macro or driver? Add it to http://www.Solutions-Zone.com
***********************************************************