Wikipedia:Reference desk/Archives/Computing/2011 August 5

= August 5 =

convert jpg to text
hi. how do I convert a jpg file to a numeric matrix? Actually I want three numeric matrices, one for red, one for green, and one for blue. Googling didn't help. I want an open source solution if possible. thanks, Robinh (talk) 08:54, 5 August 2011 (UTC)


 * What do you mean by a "numeric matrix"? Do you want a text file with the r values, expressed as, say decimals? -- Finlay McWalter ☻ Talk 11:09, 5 August 2011 (UTC)


 * This would be an easy program to write. Open the picture. Start at position 0,0 and move through to position W,H where W is the width and H is the height. Store the red, green, and blue value for each pixel. Done. You can do it with a graphics converter. When I have a chance, I will look up the image format which just stores the RGB values for each pixel (PBX is stuck it my head, but that isn't it). With that, you can open the jpg and save it in that format. Then, you just have to move the numbers around to organize them how you like. -- k a i n a w &trade; 12:44, 5 August 2011 (UTC)


 * You're probably thinking of Netpbm format. -- Finlay McWalter ☻ Talk 12:48, 5 August 2011 (UTC)


 * Yes. It is the PBM format. Open the jpg. Save it as PBM and you have a text file you can scan. -- k a i n a w &trade; 13:44, 5 August 2011 (UTC)


 * It is easy to do this from a coding perspective, but we'd need to know what language you're doing this in to give you any specific advice. Most languages of any importance already have graphical libraries for them that allow you to arbitrarily get the pixel values of many image formats. --Mr.98 (talk) 14:03, 5 August 2011 (UTC)


 * GNU Octave can load and convert JPG files using the imread function, which produces three matrices (R,G,B).. In some recent releases, though, the image-processing utilities have been buggy.  ImageMagick can also covert JPG to PBM file format.  Bear in mind that JPG files are not matrices of pixel values.  They are compressed bitstreams of macroblocks of luma/chroma data.  If you don't already know what this means, read our article on JPEG.  You may actually want to stick to a simpler file type, such as BMP, PNG, or TIFF.  For JPEG, you must learn about color space conversion, in addition to lossy compression, because a JPEG image is NOT a matrix of RGB values - it must be converted to one using a decompression and colorspace conversion algorithm.  As mentioned above, a software library exists in almost every common language to decompress JPEG and render it into RGB, but this process is sort of more steps than you might expect.  Nimur (talk) 14:42, 5 August 2011 (UTC)


 * The corollary to WP:WHAAOE, of course, is "every article needs a controversy section." But, this is a real one: I've seen so many different commercial and opensource implementations of JPEG 422 to RGB conversion... and I have seen the mysterious "travelling chroma" ghosts.... A word to the wise: if you aren't sure how your JPEG was produced, use caution poking at its RGB raster.  The RGB values are "one possible representation" of the data.  The more you convert, the more you will (possibly) drift your colorspace (depending on whether your colorconversion is adjoint-identical to the one used to create the file).  Again, note that this is entirely orthogonal to lost data due to JPEG quantization-truncating compression.  Nimur (talk) 15:01, 5 August 2011 (UTC)


 * Some comments:


 * 1) I agree with the previous comments on using the ImageMagick command suite to do the conversion.


 * 2) Be sure to specify "-compress none" as the output method, if you want it to be human-readable. However, be warned that these files are huge in such a format (around 4X the size of other uncompressed images), so expect several MB.  A 1920 × 1600 screen shot converted in this way is around 17.5 MB.


 * 3) I believe the actual command will be:

convert -compress none test.jpg test.ppm


 * (Note that the output extension is "ppm", not "pbm".)


 * 4) See the documentation on the convert command here:.


 * 5) The first 3 lines of the output file contain header info, with line 1 being the type of netpbm file created, line 2 being the image width and height in pixels, and line 3 being the maximum value allowed for R, G or B (usually 255, but not always). The remainder starts with the R, G, B values for the first pixel, then the 2nd pixel, etc.  There's a space between each value, but no other dividers, like between pixels, or image lines.  Line breaks are added periodically, possibly in the middle of a pixel (like the R value on one line, then the G and B values on the next).


 * 6) Here's some sample output:

P3 1920 1200 255 206 200 226 222 196 221 237 196 214 245 214 212 211 205 183 211 218 184 211 215 182 204 198 172 211 212 194 190 215 196 192 226 212 191 206 203  .   ..


 * StuRat (talk) 23:06, 5 August 2011 (UTC)
 * (OP). Thanks guys.  The ppm format is exactly what I am looking for.  I can use "save as" from (eg) gimp or google picasa and save in ppm format, then read it into R.  Great!   Robinh (talk) 08:00, 7 August 2011 (UTC)

Dueling monitors
I'm trying to set up a dual-monitor system, and hitting a weird roadblock.

I have an LG W2053TX. It has a DVI port in the back of it. I've hooked the DVI port to a DVI cable, which then goes to a DVI-to-HDMI adapter, which then goes into the back of the graphics card (an AMD Radeon HD 6570).

What's irritating is that the monitor does not seem to detect or know what to do with the signal it's getting. It stays black. If I cycle through the input sources, it eventually says "DIGITAL POWER SAVING MODE" and then kind of turns itself off.

Now what I find perplexing is that the computer (running Windows 7) can detect that a monitor is plugged in. It doesn't know what kind of monitor and doesn't know its correct resolution, but it thinks there is an extra monitor there.

I've tried installing all of the drivers and monitor managers and other junk from the LG website, but nothing seems to help. What am I overlooking? It's been awhile since I've messed with Windows drivers and I've not used Windows 7 much — am I forgetting something? What's the step-by-step way to get this stupid monitor to work correctly with this converter? It works fine with a raw DVI signal, but the setup requires using this DVI-to-HDMI converter (the DVI port on the graphics card is taken up by the other monitor I'm using, which can only use VGA, so a DVI-to-VGA is necessary).

Everything I've read online says that a DVI monitor should have no problem parsing an HDMI signal. The converter may be an "active" one, I don't really know how to tell them from a passive one other than the appearance, and it looks more like an active one than a passive one. But I don't know. Would that affect anything? I'm totally befuddled. --Mr.98 (talk) 14:35, 5 August 2011 (UTC)


 * One possible workaround is to use a DVI 1-to-2 splitter, like this one: . I am assuming you want the same image to appear on both screens, though.  Is this correct ? StuRat (talk) 22:47, 5 August 2011 (UTC)


 * Did you click the thing that says "Extend my desktop to this monitor"? If not, windows won't send any signal to that monitor, and it will eventually go into power-save mode like you described. APL (talk) 01:32, 6 August 2011 (UTC)


 * No, I don't want the same image to appear on both screens, I want it extended (one big desktop). So a splitter is out of the question, I believe? I have done the "extend" setting (I've tried all of the settings, honestly, just to see if I could get a signal there). Windows thinks it is sending a signal to that monitor. I think the monitor just isn't receiving it. --Mr.98 (talk) 13:15, 6 August 2011 (UTC)


 * You are correct, a splitter won't help, in your case. Just to clarify the problem, have you ever gotten any usable output from the HDMI port on your computer's graphics card ?  Also, have you tried booting the computer first, with the cables connected, and also booting the TV first, with cables connected and the computer already set to extend desktop to 2nd monitor ? StuRat (talk) 16:11, 6 August 2011 (UTC)


 * I don't have any way to test the HDMI output (no other HDMI devices). On Monday I'll try rebooting again. --Mr.98 (talk) 19:26, 6 August 2011 (UTC)


 * I would try booting without any other devices connected. If you don't see any display while booting (i.e. before Windows starts) without any (edit: I mean other of course) devices connected, most likely fooling around with Windows won't help. If Windows is not seeing the resolution etc, it sounds like it's not getting the Extended display identification data. This may cause problems setting up the display properly and may also indicate a fault either in the monitor (if it works with the DVi port native then probably not) or the cable or the converter. BTW you must have passive adapter, I'm pretty sure there no such thing there's such thing as an active HDMI to DVI (or vice versa), perhaps you're thinking of Display Port. Also since neither DVI or HDMI provide any significant power source, I'm pretty sure an active adapter will need to be connected to some external power source like USB or a DC adapter. Nil Einne (talk) 10:46, 8 August 2011 (UTC)


 * Rebooting didn't do anything. I also tried rebooting with nothing else attached — no change in things. Blah. I'll see if my IT people have another adapter we can try. --Mr.98 (talk) 13:25, 8 August 2011 (UTC)


 * Our IT guy ended up swapping out the cables, designating the HDMI-to-DVI monitor as the primary one, and THEN rebooting, and one or more of those steps seems to have fixed it, shockingly. --Mr.98 (talk) 18:41, 9 August 2011 (UTC)


 * Too bad you don't which one, in case the problem recurs. StuRat (talk) 02:12, 10 August 2011 (UTC)

Can't save my Tiddlywiki
I've been usign a Tiddlywiki successfully for a few years until today. All of a sudden I can't save my changes; I get the error message "Failed to save main Tiddlywiki file. Changes have not been saved." A separate Tiddlywiki that I use does not display this problem.

The details:
 * Firefox 5.0
 * Windows 7 (64-bit)
 * I'm not sure how to find the version # on my tiddly. The particular tiddly I'm having problems with contains a sort productivity management system called mGSD (mGSD 3.1.7 beta).

The only possibly relevant recent change - I use Outlook for my work e- mail; this morning an IT staff migrated my mail from servers owned by my employer, to some Microsoft could servers. I don't know any details of what was involved in this.

ike9898 (talk) 16:48, 5 August 2011 (UTC)


 * Make sure Firefox has permission to write to the html file, and that the file isn't in use by another process. Both things might be preventing Firefox from writing to the file. If that doesn't work, you could try going File -> Save As in Firefox and try to save your wiki under a different filename. This should save any changes you've made to the new file, so at least you won't lose your work. AvrillirvA (talk) 18:50, 6 August 2011 (UTC)

Extensible compilers & languages, compiler-compilers, metaprogramming, extensible syntax, domain specific languages, language-oriented programming
I'm very confused. Do any of them mean the same thing as the other? Are any of them related? --Melab±1 &#9742; 19:55, 5 August 2011 (UTC)


 * Some are very much related, some only remotely. Did you try articles such as extensible programming, compiler-compiler, etc - just type your terms to Wikipedia's search box at the top of this page. 88.112.59.31 (talk) 20:12, 5 August 2011 (UTC)

FORTRAN
So I have some code that I downloaded written in FORTRAN to process some data. Working on a Ubuntu 11.04 machine, I tried g95, f77, and f95 compilers and they all tell me there are errors in the code (they give me different errors). For example, one of the errors from f95 is that "ACCESS specifier in OPEN statement has invalid value 'TRANSPARENT'". f77 prints out a bunch of warnings about inconsistent called sequences and aborts compilation. g95 complains about other syntax errors. The site is ancient and the code is at least ten years old. My question is, is there anyway to find out exactly which version of FORTRAN it is written in? Are these compilers backwards compatible? Any other compilers you guys recommend I should try? Or could it be some obscure spin-off of FORTRAN? I am pretty sure the code itself is fine (whatever it is written in) because others in the past have used it to do research. I am brand new to both LINUX and FORTRAN and don't know much about them. If it would help I can also upload the source code. Its only 330 lines including a LOT of comments. Thanks! 128.138.138.122 (talk) 20:14, 5 August 2011 (UTC)


 * My knowledge of Fortran is very out of date but historically input and output from disk was always problematic between versions. It looks to me that your program may have been written in Lahey Fortran where access=transparent is a nonstandard extension. gfortran may the way to go but frankly my suggestion is to mug up on enough Fortran to understand the mathematical logic being used (with luck you may be able to treat it as pseudocode) and then write your own code from scratch using a language you are familiar with. The Lahey article gives advice for porting (but in the "wrong" direction) and suggests to me the input read following the OPEN statement may be from a disk file created using a different programming language.Thincat (talk) 22:21, 5 August 2011 (UTC)


 * Fortran programmer here. I agree that it sounds like the code was written using non-standard extensions.  If you can provide the source code and any input required, I'll take a look.  It might be easier to just rewrite the non-standard parts, provided I can figure out what they did, than start from scratch. StuRat (talk) 22:41, 5 August 2011 (UTC)

OP here. Here is the source code in FORTRAN. If you'd like a pair of sample input files, I can provide those too. Thanks! 174.29.65.10 (talk) 03:24, 6 August 2011 (UTC)


 * I'll not even attempt to offer a solution to your problem, but I can't help but comment that programming languages have improved over the years... AndyTheGrump (talk) 03:56, 6 August 2011 (UTC)
 * Are you daring to suggest that the skills I learnt in 1967 are no longer bleeding edge? (I still have a copy of my first program. It solved quadratic equations.) HiLo48 (talk) 04:01, 6 August 2011 (UTC)
 * I don't go back quite that far (BBC Basic was my first programming language), but I can see the advantages of actually moving beyond the palaeolithic stage of coding. In the good old days, you spent hours writing a program to do something simple, only to discover it didn't work. Nowadays you can write programs to do much more complex things, and get exactly the same result ;-) AndyTheGrump (talk) 04:16, 6 August 2011 (UTC)


 * Yes, please provide the input files. If they aren't too long, you can just put them as text here (like you did with the source code).


 * OK, I was able to get it to compile, using GFortran, with 3 fixes:


 * 1) Removed the ACCESS='TRANSPARENT' clause.


 * 2) Removed the FLEN clause.


 * 3) Fixed one print statement.


 * I'm not sure if just removing those 2 clauses is OK, though; we might need to find another way to do the same thing. On a successful compile I got warnings that two functions weren't found.  One is TIMER, which seems to get the CPU time.  There are other ways to do this, or we could just disable the CPU time calcs.  The other is CHARNB, which appears to just format the print of the file name.  We can leave the name unformatted or print it in another way.  So, with these changes it should run.  StuRat (talk) 04:08, 6 August 2011 (UTC)


 * Regarding the ACCESS='TRANSPARENT' Lahey extension. Here's what it does, according to the link provided above:

Converting unformatted files with LF90 or LF95 usually involves opening the file using the specifier ACCESS="TRANSPARENT" (a nonstandard Lahey extension), which allows the file to be read a byte at a time with no assumptions about headers or record delimiters. This allows one to have the same degree of control as when handling files in the C language.


 * I believe GFortran uses the FGETC function to accomplish the same thing: . StuRat (talk) 04:18, 6 August 2011 (UTC)


 * Regarding the FLEN specifier in the INQUIRE statement, that extension appears to return the length, in bytes, of the file . I don't know of an easy way to do that in GFortran.  One option would be to append an EOF character to the end of the file, and read until that point.  This is relatively simple, provided there is some character we can use which won't appear in the bulk of the program.  Another option is to read until we get an EOF error, and catch that.  This can be a bit messy, as I recall. StuRat (talk) 04:38, 6 August 2011 (UTC)


 * Regarding the TIMER function, the CPU_TIME function appears to be standard Fortran to do the same thing, although it returns a real number, versus hundredths of a second returned as an integer in the TIMER function.  A minor change to the code will adjust for this. StuRat (talk) 04:50, 6 August 2011 (UTC)

Here is the link to the input files. There are two of them in there. One is the header file and the other is the ephemeris file to which the code refers. They are both in binary and I don't know if it matters but I have good reason to believe that the developer was working on a little endian system.174.29.65.10 (talk) 06:03, 6 August 2011 (UTC)


 * Those seem to be packed into a single RAR file. I'm on Windows XP, and don't have a way to unpack those.  Could you upload each file separately (so hopefully they won't be packed into a RAR file) ?  What are the names and extensions of the two files ? StuRat (talk) 06:48, 6 August 2011 (UTC)

This is the cr0006.hed header file and this is the cr0006.eph ephemeris file. The extensions are just a label because both files are just binaries.174.29.65.10 (talk) 07:39, 6 August 2011 (UTC)


 * OK, I will take a look and see what I can come up with. BTW, I see this all deals with the orbits of satellites.  May I ask where you work ? StuRat (talk) 16:08, 6 August 2011 (UTC)


 * I got it to compile and link, but am getting run-time errors. Here's my output:

CRRES EPHEMERIS PROGRAM VER. 1.01

This version of ephemer requires EORs in th .EPH file INPUT FILE NAME? cr0006.eph FILE cr0006.HED                    IS    53241 BYTES (  103+ SECTORS) LONG Vehicle ID   =            0                    Experiment ID =            0 Orbit Number =            0                    Julian Date   =            0 Year         =            0                    Day of Year   =     50856192 UT Start of Data =    0.000                    UT End of Data =       0.000 UT First Perigee =    0.000                    VTCW at Start =            0 VTCW at End  =            0                    Agency Tape Date =         0 Missing Maj Frames        0                    Filled Minor Frms          0

Penumbra Start =  *********                    Penumbra Stop =    ********* Umbra Start  =        0.000                    Umbra Stop    =        0.000 Penumbra Start =      0.000                    Penumbra Stop =        0.000 Umbra Start  =        0.000                    Umbra Stop    =        0.000 VTCW         =            0                    UT            =        0.000 VTCW         =            0                    UT            =        0.000 VTCW         =            0                    UT            =        0.000

FILE cr0006.EPH                    IS    53241 BYTES (  103+ SECTORS) LONG WRITE OUTPUT TO THE SCREEN (1), FILE (2), OR BOTH (3) 3  PAUSE DISPLAY BETWEEN FRAMES? (YES=1,NO=2) 1  DO YOU WANT THE PLOT FORMAT FILE? (Y,N) y  OUTPUT FILE NAME? cr0006.out At line 231 of file wikiref.f (unit = 1, file = 'cr0006.EPH') Fortran runtime error: Read past ENDFILE record


 * I suspect that it's not actually reading from the file, yet, because of all those zeros. It would help to know what the output should look like, though, and what the input data looks like (in human-readable form). StuRat (talk) 17:42, 6 August 2011 (UTC)

Well I have no idea what the input should look like. Its just binary data (probably raw data from the satellite) but I don't know the format. You can probably deduce that from the FORTRAN code. The output I think should be tables of single precision numbers (probably with 60 rows or something like how it says in the comments). The output should be various magnetic field and particle measurements along with longitude, latitude, and altitude where the measurements were taken.174.29.65.10 (talk) 21:39, 6 August 2011 (UTC)


 * Right, but I need the specific output expected for this data file, to know if it's working properly. Right now all I get is a bunch of zeros, for the most part, so that's probably wrong, but even if I get a bunch of random looking numbers, that could still be right or wrong, how can I tell ? StuRat (talk) 22:06, 6 August 2011 (UTC)


 * Ok, since this section will soon be archived, let's continue this discussion on my talk page. StuRat (talk) 02:59, 9 August 2011 (UTC)

My computer has gone mute
My laptop was running very slow, so I did a system restore, deleted some programs I rarely use from add/remove programs, and updated my symantic virus protection...in that exact order. Everything works great, except now there is no audio. I've checked all the volume controls, system tools and anything else related to audio. Nothing. What could I have possibly done to disable the audio? Any idea how I can fix this? Quinn &#10048; BEAUTIFUL DAY 20:37, 5 August 2011 (UTC)


 * Reinstall audio device driver? ¦ Reisio (talk) 23:51, 5 August 2011 (UTC)

Yeah, sounds great, but how? Quinn &#10048; BEAUTIFUL DAY 00:02, 6 August 2011 (UTC)


 * If it's a preassembled computer like a Dell or an HP or something like that, go to the manufacturer's website look up your model, download the driver/s and install them. ¦ Reisio (talk) 00:19, 6 August 2011 (UTC)
 * Ok, so I went to Toshiba and updated my driver. I get something called the Driver Detective, which runs, then wants me to enter a credit card.  I stopped at that point. Quinn &#10048; BEAUTIFUL DAY  01:31, 6 August 2011 (UTC)
 * Go to toshiba.com, click on "Services and Support" → "Consumer Products" → "Laptops, Multimedia Notebooks, & Accessories" → "Tech Support". That brings you here. Now choose your model number. Is that where you downloaded that program that wants your credit card number? I hope not. -- BenRG (talk) 02:27, 6 August 2011 (UTC)
 * OK that worked! Brilliant! Thanks! Quinn &#10048; BEAUTIFUL DAY 04:25, 6 August 2011 (UTC)