Comment On Interesting Bitmap

As a programmer for a steel mill, Josh gets to see all sorts of interesting things. And not the "everyday" things like the gargantuan ladles that carry hundreds of tons of molten steel. Or the red-hot, 2000°F slabs flying through the hydraulic rollers in the hot strip mill. Or even the giant vats of hydrochloric and sulfuric acid used by the pickler. No, I'm talking about The Code. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Interesting Bitmap

2009-06-05 09:01 • by kastein
Another steel mill story? wow... and my senior project was related to this (the steel mill stuff, not the signature handling XMLAOTD (XML Abuse Of The Day)).

Note: my senior project mostly caught fire. Thermal runaway in motor drivers is my worst nightmare.

Re: Interesting Bitmap

2009-06-05 09:07 • by @Deprecated (unregistered)
267364 in reply to 267363
XML meta: ~50 chars
payload: 2 to 3 chars
6% payload;

The real WTF is that they didn't use JSON!

Ah but seriously, what's with the two layers of tags?
Someone was itching to use this new-fangled XML stuff.

Re: Interesting Bitmap

2009-06-05 09:08 • by Dinnerbone
Alex:
<Signature
<signature>
87
</signature>
</Signature>
<Signature>
<signature>
127
</signature>
</Signature>

Well there's your problem. You're not closing the initial <Signature> tag.

Re: Interesting Bitmap

2009-06-05 09:17 • by ContraCorners
>> And not the "everyday" things like the gargantuan ladles that carry hundreds of tons of molten steel...

It took me a second to realize that didn't say gargantuan ladies.

Must remember to have coffee before reading.

Re: Interesting Bitmap

2009-06-05 09:18 • by Man of Steel (unregistered)
Ummm, that's not X Y data. At best it might be the value of each consecutive pixel, with the X Y coordinates implied. But, you said it wasn't a color image.

I call BS. Or confusion, which is close enough to the same thing.

Re: Interesting Bitmap

2009-06-05 09:19 • by Roy (unregistered)
I would've expected
<signature>
<pixel>
<x>3</x>
<y>53</y>
</pixel>
...
</signature>

I don't even understand how they use this stuff or what crazy thoughtprocess made this come into existence.

(Yeah I do understand that using xml for this is a total wtf)

Re: Interesting Bitmap

2009-06-05 09:20 • by Kazan
267369 in reply to 267364
@Deprecated:
XML meta: ~50 chars
payload: 2 to 3 chars
6% payload;

The real WTF is that they didn't use JSON!

Ah but seriously, what's with the two layers of tags?
Someone was itching to use this new-fangled XML stuff.


the Real WTF is that they didn't use Ice (ZeroC) or it's crappier ancestor CORBA.

but JSON would have been ok was well...

for an ICE payload it would be very little overhead + the binary size of the array. overhead is fixed. O+N*sizeof(typeof(N))

for a JSON payload [assuming 2 byte average per datapoint] 2 + 2*N + N where 2*N characters of that are payload and 2+N are overhead. if you don't pack it with spaces (Which are unneeded since it is generated data anyway)

Re: Interesting Bitmap

2009-06-05 09:22 • by Kazan
267370 in reply to 267367
Man of Steel:
Ummm, that's not X Y data. At best it might be the value of each consecutive pixel, with the X Y coordinates implied. But, you said it wasn't a color image.

I call BS. Or confusion, which is close enough to the same thing.


you can address an X-Y space with consecutive numbers if you map it correctly

N = the value given
Sx = Width
Sy = Height
Origin = topleft.

X = int(N / Sx)
Y = N % Sx

IIRC.. i tried to remember that real fast.. might be in error.

Re: Interesting Bitmap

2009-06-05 09:23 • by XML Blasta (unregistered)
267371 in reply to 267368
Roy:
I would've expected
<signature>
<pixel>
<x>3</x>
<y>53</y>
</pixel>
...
</signature>

I don't even understand how they use this stuff or what crazy thoughtprocess made this come into existence.

(Yeah I do understand that using xml for this is a total wtf)


Geez, whatta XMLn00b.

The best, most clearly-normalized format would have to be
<signature>
<pixel x=0 y=0>
0
</pixel>
<pixel x=1 y=0>
0
</pixel>
<pixel x=2 y=0>
1
</pixel>
<pixel x=3 y=0>
0
</pixel>
...
</signature>

Really.

The basic rule of XML is "XML is like violence. If it isn't solving your problem yet, you're not using enough of it."

Re: Interesting Bitmap

2009-06-05 09:25 • by Dave D Drawer (unregistered)
No, no, no, if you want to waste bytes, put your X Y data in VRML!


#VRML V2.0 utf8

Shape {
appearance Appearance {
material Material {
emissiveColor 0.8 0.8 0.8
}
}
geometry PointSet {
coord Coordinate {
point [
3 17 0
]
}
}
}


NavigationInfo {
type [ "EXAMINE", "FLY", "WALK", "ANY" ]
speed 1.0
}

Re: Interesting Bitmap

2009-06-05 09:26 • by Jim Lard (unregistered)
I mis-read "gargantuan ladles" in the first paragraph as "gargantuan ladies". Then got all excited when it started talking about the "hot strip mill"...

Creating a hostile workplace environment aside, this story is an excellent example of why XML is not always your friend.

Re: Interesting Bitmap

2009-06-05 09:27 • by Xanthir, FCD (unregistered)
267374 in reply to 267364
XML meta: ~50 chars
payload: 2 to 3 chars
6% payload;

That's only if you're still thinking like the developer who wrote the original. This is a *bitmap*. A black and white bitmap, at that. Let's be charitable and say that the signature field is 400px by 300px. That's 1200 bits of data, or 150 bytes. Just shoot that binary data at the bitmap creator and you're golden.

Compare that to 50 bytes per block times 1000 such blocks for 50kB of data, and your actual payload is .3%.

Even with full 32-bit color, they could have stored it with 4 bytes per block. The size of the XML at that point, though...

(Also, had they used JSON, they could have serialized the whole thing as "[127,43,54,...]" and gotten a ~75% payload.)

Re: Interesting Bitmap

2009-06-05 09:28 • by Code Dependent
267375 in reply to 267366
ContraCorners:
>> And not the "everyday" things like the gargantuan ladles that carry hundreds of tons of molten steel...

It took me a second to realize that didn't say gargantuan ladies.

Must remember to have coffee before reading.
Me too. Good for a smile, though.

Re: Interesting Bitmap

2009-06-05 09:30 • by Basseq (unregistered)
267376 in reply to 267371
The uncompressed bitmap data transmitted through the webservice weighed in at about 290KB.


The resulting XML looked like this...


So XML is "uncompressed bitmap data" now?

TRWTF is the contradictions in this story, which can be summarized as "Past developer used XML badly." You're welcome, Daily WTF. I just saved you 20KB in "uncompressed bitmap data" (or "characters" if we're being all LOGICAL).

Re: Interesting Bitmap

2009-06-05 09:31 • by Man of Steel (unregistered)
267377 in reply to 267370
Kazan:
Man of Steel:
Ummm, that's not X Y data. At best it might be the value of each consecutive pixel, with the X Y coordinates implied. But, you said it wasn't a color image.

I call BS. Or confusion, which is close enough to the same thing.


you can address an X-Y space with consecutive numbers if you map it correctly

N = the value given
Sx = Width
Sy = Height
Origin = topleft.

X = int(N / Sx)
Y = N % Sx

IIRC.. i tried to remember that real fast.. might be in error.

The examples given, 87 and 127, don't contain enough bits to encode X and Y in a single number, unless the resulting bitmap is very small. Well I suppose X could have been 0 in both cases and the signature line went from Y=87 to Y=127 but that seems improbable for a signature capture.

Re: Interesting Bitmap

2009-06-05 09:32 • by BBT (unregistered)
Presumably the thinking was this:

"Signatures...Hmmmm...Well, in handwriting analysis, you don't just look at the picture, you actually look and see whether they wrote it in the right order (like they started from the top of the letter vs from the bottom). It's true, I saw it on CSI last night. We'd better store each individual pixel they go over, in order, so that we can check that it's not a forgery."

Never mind that the requirement was just to store the images. And they would never need to check for forgeries. And they didn't have an algorithm to detect forgeries anyway.

On that note, the real wtf is that they didn't store pressure data which is effective for detecting forgeries!

Re: Interesting Bitmap

2009-06-05 09:32 • by That Troper (unregistered)
"And not the "everyday" things like the gargantuan ladles that carry hundreds of tons of molten steel."

I read this as "gargantuan ladies"

Re: Interesting Bitmap

2009-06-05 09:34 • by Prometheus (unregistered)
<Comment>
<comment>
I ain't first
</comment>
</Comment>

I think a lot of us in the wee hours of the morning misread that as "ladies" Me included.

Re: Interesting Bitmap

2009-06-05 09:35 • by Adam Jorgensen (unregistered)
267381 in reply to 267378
BBT:
Presumably the thinking was this:

"Signatures...Hmmmm...Well, in handwriting analysis, you don't just look at the picture, you actually look and see whether they wrote it in the right order (like they started from the top of the letter vs from the bottom). It's true, I saw it on CSI last night. We'd better store each individual pixel they go over, in order, so that we can check that it's not a forgery."

Never mind that the requirement was just to store the images. And they would never need to check for forgeries. And they didn't have an algorithm to detect forgeries anyway.

On that note, the real wtf is that they didn't store pressure data which is effective for detecting forgeries!


No, I'm guessing it's more likey the original dev was just plain stupid.

Honestly, binary data is not exactly black magic...

And if you absolutely had to send it via a webservice, wouldn't a binary protocol like Hessian make this trivial?

Re: Interesting Bitmap

2009-06-05 09:37 • by Stef Nighthawk (unregistered)
267382 in reply to 267371
XML Blasta:

Geez, whatta XMLn00b.

The best, most clearly-normalized format would have to be
<signature>
<pixel x=0 y=0>
0
</pixel>
<pixel x=1 y=0>
0
</pixel>
<pixel x=2 y=0>
1
</pixel>
<pixel x=3 y=0>
0
</pixel>
...
</signature>

Really.

The basic rule of XML is "XML is like violence. If it isn't solving your problem yet, you're not using enough of it."

How's about
<signature>
<row y=0>
<pixel x=0>
0
</pixel>
<pixel x=1>
1
</pixel>
<pixel x=2>
0
</pixel>
...
</row>
<row y=1>
<pixel x=0>
0
</pixel>
...
</row>
...
</signature>

Re: Interesting Bitmap

2009-06-05 09:38 • by Xanthir, FCD (unregistered)
267383 in reply to 267374
Xanthir, FCD:
XML meta: ~50 chars
payload: 2 to 3 chars
6% payload;

That's only if you're still thinking like the developer who wrote the original. This is a *bitmap*. A black and white bitmap, at that. Let's be charitable and say that the signature field is 400px by 300px. That's 1200 bits of data, or 150 bytes. Just shoot that binary data at the bitmap creator and you're golden.

Compare that to 50 bytes per block times 1000 such blocks for 50kB of data, and your actual payload is .3%.

Even with full 32-bit color, they could have stored it with 4 bytes per block. The size of the XML at that point, though...

(Also, had they used JSON, they could have serialized the whole thing as "[127,43,54,...]" and gotten a ~75% payload.)

Well, first, I've obviously just woken up, because 400x300 is 120000 bits, or 15000 bytes. 15k. This makes my experimental evidence (a 400x300 monochrome bitmap produced in MS Paint) make sense, as it's 15662 bytes in size.

And, rereading the article, I see that the signatures are actually 300x100. So 30000 bits, 3750 bytes. Thus, this approach is pretty comparable to recording just the black bits in a sparse array. Given a decent packed encoding (number the pixels consecutively, so you can store them in 2 bytes), and 1000 black pixels, you've got the entire thing stored in 2kB.

Intelligent choice of data structures ftw!

Re: Interesting Bitmap

2009-06-05 09:38 • by Neil (unregistered)
267384 in reply to 267366
ContraCorners:
>> And not the "everyday" things like the gargantuan ladles that carry hundreds of tons of molten steel...

It took me a second to realize that didn't say gargantuan ladies.

Must remember to have coffee before reading.

Hah! You did better than me. I thought it said ladies until I read your comment. :P

Re: Interesting Bitmap

2009-06-05 09:40 • by anon (unregistered)
Fahrenheit? Speak SI, dammit!

Re: Interesting Bitmap

2009-06-05 09:42 • by JayC (unregistered)
267387 in reply to 267380
Prometheus:
<Comment>
<comment>
I ain't first
</comment>
</Comment>

I think a lot of us in the wee hours of the morning misread that as "ladies" Me included.


Still fun to visualize, though... that's the true essence of a WTF!

Re: Interesting Bitmap

2009-06-05 09:42 • by Neil (unregistered)
267388 in reply to 267385
anon:
Fahrenheit? Speak SI, dammit!

Sports Illustrated?

Re: Interesting Bitmap

2009-06-05 09:47 • by AndrewB (unregistered)
When I first read that the 300x100 black and white image took up 290kb, I said to myself in my head "Haha, what, are they storing it in XML or something?"

I'm not laughing any more.

Re: Interesting Bitmap

2009-06-05 09:51 • by another anon (unregistered)
267390 in reply to 267385
anon:
Fahrenheit? Speak SI, dammit!


2000 degrees Fahrenheit is approximately "a billion degrees" in Celsius and "a billion - 273" Kelvin.

Re: Interesting Bitmap

2009-06-05 09:55 • by Dinnerbone
267391 in reply to 267390
another anon:
anon:
Fahrenheit? Speak SI, dammit!


2000 degrees Fahrenheit is approximately "a billion degrees" in Celsius and "a billion - 273" Kelvin.


If billion === thousand, and 273 == -273.

Oh god, 273 == -273. The universe goes boom.

Re: Interesting Bitmap

2009-06-05 09:55 • by Satanicpuppy
267392 in reply to 267368
Roy:
I would've expected
<signature>
<pixel>
<x>3</x>
<y>53</y>
</pixel>
...
</signature>

I don't even understand how they use this stuff or what crazy thoughtprocess made this come into existence.

(Yeah I do understand that using xml for this is a total wtf)


The thing is, you could just as easily do:
<signature>
<pixel>
3,53
</pixel>
...
</signature>

...And cut your xml in half. To be even crazier, you could remove the xml entirely and just do a big comma separated list: x,y,x,y,x,y,x,y,etc.

Really though, you should just offload the work to the data input device and get it to send you a fricking jpeg. This isn't 1981.

Re: Interesting Bitmap

2009-06-05 09:58 • by valerion
Ah, XML. The cause of, and solution to, all of life's problems.

Re: Interesting Bitmap

2009-06-05 09:59 • by Satanicpuppy
267394 in reply to 267383
Xanthir, FCD:
Xanthir, FCD:
XML meta: ~50 chars
payload: 2 to 3 chars
6% payload;

That's only if you're still thinking like the developer who wrote the original. This is a *bitmap*. A black and white bitmap, at that. Let's be charitable and say that the signature field is 400px by 300px. That's 1200 bits of data, or 150 bytes. Just shoot that binary data at the bitmap creator and you're golden.

Compare that to 50 bytes per block times 1000 such blocks for 50kB of data, and your actual payload is .3%.

Even with full 32-bit color, they could have stored it with 4 bytes per block. The size of the XML at that point, though...

(Also, had they used JSON, they could have serialized the whole thing as "[127,43,54,...]" and gotten a ~75% payload.)

Well, first, I've obviously just woken up, because 400x300 is 120000 bits, or 15000 bytes. 15k. This makes my experimental evidence (a 400x300 monochrome bitmap produced in MS Paint) make sense, as it's 15662 bytes in size.

And, rereading the article, I see that the signatures are actually 300x100. So 30000 bits, 3750 bytes. Thus, this approach is pretty comparable to recording just the black bits in a sparse array. Given a decent packed encoding (number the pixels consecutively, so you can store them in 2 bytes), and 1000 black pixels, you've got the entire thing stored in 2kB.

Intelligent choice of data structures ftw!


I've dealt with too much COBOL in my time to try and optimize the data storage for size in all but the most extreme circumstances. Size and Cycles are cheap; the data structure needs to be optimized for speed and reliability.

Not that this does that either. But the size isn't what bothers me about it.

Re: Interesting Bitmap

2009-06-05 10:08 • by Pfhreak (unregistered)
Not that they did this the right way at all, but remember that they were trying to capture signatures here. Not just images of signatures. Things like the direction a letter is drawn might be checked if you have the consecutive point data rather than a monochrome bitmap.

Re: Interesting Bitmap

2009-06-05 10:08 • by Voodoo Coder
So, you're saying, if I notice my developers working out calculus functions on a white board while trying to figure out how to store a signature bitmap...I should be concerned?

Sometimes, I like to insert this type of problem solving technique into other professions in my mind, such as a doctor!

"Sure, we could remove the splinter in your index finger with tweezers, but I just got all this fancy new laproscopic equipment and I've been dying to try it out! Let's try getting at it through the belly button!"

Re: Interesting Bitmap

2009-06-05 10:16 • by Kazan
267398 in reply to 267377
Man of Steel:

The examples given, 87 and 127, don't contain enough bits to encode X and Y in a single number, unless the resulting bitmap is very small. Well I suppose X could have been 0 in both cases and the signature line went from Y=87 to Y=127 but that seems improbable for a signature capture.


or it (the bit shown int he article) is a snippet of a sparse array

Re: Interesting Bitmap

2009-06-05 10:18 • by ObiWayneKenobi
The Code — the lifeblood of the steel mill's information system applications — was originally developed by a highly paid consulting firm who specialized in the manufacturing industry and hired "only the brightest of developers".


Whenever you hear or read something like this, you know that things are going to get very, very ugly.

Re: Interesting Bitmap

2009-06-05 10:19 • by Darren (unregistered)
267400 in reply to 267392
Satanicpuppy:
Really though, you should just offload the work to the data input device and get it to send you a fricking jpeg. This isn't 1981.


Ok, firstly: a lossy image format for signature data? You're nuts, friend.

Secondly, the web service probably required XML input (that's how these requirements go: "thou shalt use SOAP and XML for the webservice"), so "just sending an image" wouldn't be a great solution.

There's also the need to think ahead about future requirements that might change the image size or require color (stupider regulations have been passed).

So here's what I would do:

A 300x100 monochrome image is just an array of 30000 bits. I would have packed this into 3750 bytes, then Base64 encoded the whole thing, and slipped it into the webservice payload thus:

<signature width="300" height="100" color="no">
<image encoding="base64">....encdoded data here...</image>
</signature>

Re: Interesting Bitmap

2009-06-05 10:27 • by DOA
267403 in reply to 267371
XML Blasta:
Geez, whatta XMLn00b.

The best, most clearly-normalized format would have to be
<signature>
<pixel x=0 y=0>
0
</pixel>
...
</signature>

Really.

The basic rule of XML is "XML is like violence. If it isn't solving your problem yet, you're not using enough of it."
Heh,
+1 internets for proper use of XML.

Re: Interesting Bitmap

2009-06-05 10:37 • by OzPeter
In a similar vein I worked on a job where we wanted to punt around large amounts of numerical data from a Hot Strip Mill setup program to a logging system.

We proposed an ASN.1 solution that would minimise the data volume and was easily extensible if you wanted to add more data to the log.

But did they go with that?? Nope .. they ended up with an XML solution which multiplied the dataset size by a huge amount and if you wanted to change the dataset you had to edit and recompile the setup program.

Re: Interesting Bitmap

2009-06-05 10:38 • by ubersoldat
Doesn't seem like a bad idea, very enterprisy in my opinion. At least the won't have a hard time comparing signatures... oh wait!

Re: Interesting Bitmap

2009-06-05 10:41 • by Ben (unregistered)
267406 in reply to 267400
Why do we need to pass it to the server if it's base64?

Re: Interesting Bitmap

2009-06-05 10:44 • by evilspoons
267407 in reply to 267400
Darren:
Satanicpuppy:
Really though, you should just offload the work to the data input device and get it to send you a fricking jpeg. This isn't 1981.


Ok, firstly: a lossy image format for signature data? You're nuts, friend.


JPEG doesn't have to be lossy, does it? I thought at 100% in certain encoders it is lossless.

At any rate, just stick the damn thing in as a PNG or a GIF or something. I don't think JPEG is very efficient in monochrome (although I could be wrong).

Re: Interesting Bitmap

2009-06-05 10:50 • by Code Dependent
267408 in reply to 267399
ObiWayneKenobi:
The Code — the lifeblood of the steel mill's information system applications — was originally developed by a highly paid consulting firm who specialized in the manufacturing industry and hired "only the brightest of developers".
Whenever you hear or read something like this, you know that things are going to get very, very ugly.
Yeah, but it builds suspense so much better than, "...a reasonably paid consulting firm with no particular specialty who hired average developers."

Re: Interesting Bitmap

2009-06-05 10:51 • by Beldar the Phantom Replier
267409 in reply to 267391
Dinnerbone:
Oh god, 273 == -273. The universe goes boom.


That makes perfect sense iff 273 == i

Re: Interesting Bitmap

2009-06-05 10:58 • by Chelloveck (unregistered)
267410 in reply to 267407
evilspoons:
At any rate, just stick the damn thing in as a PNG or a GIF or something. I don't think JPEG is very efficient in monochrome (although I could be wrong).


You're not wrong. JPEG is really freakin' awful for monochrome images. It's also pretty bad at any line-art like a cartoon or logo, color or mono. JPEG compresses smooth color gradients, not sharp transitions. Encoding a line drawing as JPEG gives it all sorts of really nasty compression artifacts.

JPEG would be the worst possible image format for a monochrome signature. With the possible exception of XML, of course.

Re: Interesting Bitmap

2009-06-05 10:58 • by Zemm
267411 in reply to 267391
Dinnerbone:
another anon:
anon:
Fahrenheit? Speak SI, dammit!


2000 degrees Fahrenheit is approximately "a billion degrees" in Celsius and "a billion - 273" Kelvin.


If billion === thousand, and 273 == -273.


http://www.google.com.au/search?q=2000f+in+c

But the second part is "a billion - 273" as in 999999727 "another anon Kelvin".

Re: Interesting Bitmap

2009-06-05 11:12 • by blindman (unregistered)
XML is a virus.

Re: Interesting Bitmap

2009-06-05 11:13 • by Grimoire
This sounds like the app I worked on at my previous job. We bought a company that made remote inspection software, and it was full of crap like this. It sounds *exactly* like Echo by Infowave (previously Telispark). The guy who wrote the original did some crazy stuff like storing strokes of the signature instead of storing the binary bitmap.

I would not at all be surprised if this was Telispark...

Re: Interesting Bitmap

2009-06-05 11:13 • by Alan (unregistered)
267414 in reply to 267400
Darren:

So here's what I would do:

A 300x100 monochrome image is just an array of 30000 bits. I would have packed this into 3750 bytes, then Base64 encoded the whole thing, and slipped it into the webservice payload thus:

<signature width="300" height="100" color="no">
<image encoding="base64">....encdoded data here...</image>
</signature>


Thats no fun - I would have converted it to ascii art.

Re: Interesting Bitmap

2009-06-05 11:31 • by Big Bertha (unregistered)
267417 in reply to 267373
Jim Lard:
I mis-read "gargantuan ladles" in the first paragraph as "gargantuan ladies". Then got all excited when it started talking about the "hot strip mill"...
I'm a gargantuan lady, you insensitive clod!

Re: Interesting Bitmap

2009-06-05 11:33 • by Dave (unregistered)
It must be Friday. I read the second sentence as 'And not the "everyday" things like the gargantuan ladies that carry hundreds of tons of molten steel.'
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment