- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there
Yeh the data file being read is a multiple lines one. I have attached it for you to see.
The purpose of this code (I'm told) is to read the ASCII file in and export a reordered single column of data which will then be used in a second inherited code
UPDATE:
Seems the upload didn't work. Here is the file forviewing from my DB http://dl.dropbox.com/u/3076541/img28cropped.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
as TimP said the "resolution" of your integers in rows and columns should be correct (236x121 ??). I can't download your file, so I just guess it contains 236 rows and 121 columns of (space separated?) integers (i3). So maybe the modified code works:
[bash]program reorder ! ! Re-orders the pixels to convert to crsfrqs required ! input format... ! implicit none integer, parameter :: irow=512, icol=512 ! this is the resolution of your pic integer :: i,j,k,l,pix(irow,icol) character*12 :: yname,newname ! print*,'Please enter the name of your visilog file' print*,'(12 chars max, also type the extension)' read(*,'(a12)') yname ! print*,'Enter the name for your new file:' print*,'(12 chars max, also type the extension)' read(*,'(a12)') newname ! print*,'WORKING......' 9 open(9,file=yname, status='unknown') open(2,file=newname, status='unknown') ! ! pix = 0 ! ! Read and re-order... ! ! i is x cord... ! do i=1,irow read (9,*) pix(i,1:icol) end do ! ! Write out in the preferred format into the new file... ! do 30 k=1,irow do 40 l=1,icol if(pix(k,l).gt.100)then pix(k,l)=0 elseif(pix(k,l).lt.100)then pix(k,l)=255 else continue endif write(2,'(i3)')pix(k,l) 40 continue 30 continue ! write (*,*) 'Program converted in ',newname write (*,*) 'Bye Bye.' ! continue close(9) close(2) end [/bash]You will have to correct the rows and columns (irow,icol) in it. If the integers are not space seperated, you will have to use in line 31 something like this:
[fortran]read (9,'(
But I'm not sure, whether the latter works.
Kind regards,
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure why the download doesn't work. I am new to this forum but if you put the previously posted URL into your browser you will be able to view it.
If not you can try downloading here
As for the code you posted, I did try it (with both versions of line 31) but sadly no joy.
The aim of this code is to reorder a collection of ASCII characters on a 236x121 matrix. There are no spaces in between the characters. This used to be an image until it was converted in MATLAB to a .txt file.
Thank you for your help but something still isn't working. Appriciate the effort though!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a question regarding your input file.It looks like a verydownsampledMRI-image. So, is that a correct input image?

Best regards,
Sergey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
now as I saw the ASCII I think I understand what the code should do. It reads a character and convert it into an three digit integer (0 to 255). I modified the code (you should uncomment the file name read in part, if you change your file name, be careful of length), and the read parts works, but I'm not sure, whether the output in one column is that what you want. It depends on the next program in your tool chain...
Kind regards,
Johannes
ps: The read line 35 works fine with IFORT but won't with GCC!
[fortran]program reorder ! ! Re-orders the pixels to convert to crsfrqs required ! input format... ! implicit none integer, parameter :: irow=121, icol=236 ! this is the resolution of your pic integer :: i,j,k,l,pix(irow,icol) character*80 :: yname,newname character(len=1),dimension(irow,icol) :: pixc ! ! print*,'Please enter the name of your visilog file' ! print*,'(12 chars max, also type the extension)' ! read(*,'(a12)') yname yname(1:16) = 'img28cropped.txt' !! ! print*,'Enter the name for your new file:' ! print*,'(12 chars max, also type the extension)' ! read(*,'(a12)') newname newname(1:20) = 'img28cropped_new.txt' ! print*,'WORKING......' 9 open(9,file=yname, status='unknown') open(2,file=newname, status='unknown') ! ! pix = 0 pixc = ' ' ! ! Read and re-order... ! ! i is x cord... ! do i=1,irow read (9,'(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
:-)
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd like to provide additional information:
1. I've downloaded a 'img28cropped.txt' file
2. Opened the file in an editor as binary and manually deleted all New Line and Carriage return
characters ( 0x0D & 0x0A )
3. Saved as a new file
4. Opened the new file with ImageJ as a Raw image with dimensions 235 by 121 and 8-bit type
A note for the Step 2:
Source image looks like ( '...' means skipped characters or '***' skipped rows ):
@@@@@...@@@@@DA
@@@@@...@@@@@DA
@@@@@...@@@@@DA
***
@@@@@...@@@@@DA
@@@@@...@@@@@DA
@@@@@...@@@@@DA
Width ( Columns ) = 235
Height ( Rows ) = 121
'DA' means two hex-characters 0x0D and 0x0A
Converted image looks like ( '...' means skipped characters or '***' skipped rows ):
@@@@@...@@@@@@@@@@...@@@@@@@@@@...@@@@@***@@@@@...@@@@@@@@@@...@@@@@@@@@@...@@@@@
All New Line and Carriage return characters ( 0x0D & 0x0A ) deleted anddata could be loaded
into a matrix.
Note: ImageJ is an application widely used by Software Developers working on image processing projects.
Best regards,
Sergey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page