Hi,
Could anyone tell me what is the simplest code to read a 8-bit
grayscale JPEG image using C.
Thanks a ton,
Speed 10 5670
Speed wrote:
Hi,
Could anyone tell me what is the simplest code to read a 8-bit
grayscale JPEG image using C.
Well, the simple answer is that you open the file with fopen() in
binary mode, and read the data with fread().
However, that's not likely what you are asking. If you're asking
whether C has facilities for image handling, then the answer is no.
You'll have to find a library with a C API for that. the platform you
intend to use will be important.
I recommend a Google search, or ask on a newsgroup dedicated to image
processing.
Brian
Speed wrote, On 18/07/07 23:06:
Hi,
Could anyone tell me what is the simplest code to read a 8-bit
grayscale JPEG image using C.
FILE *jpeghandle = fopen(jpegname,"rb");
if (jpeghandle)
while (getc(jpeghandle)!=EOF);
The above will work given an appropriate definition and initialisation
of jpegname on systems with CHAR_BIT==8.
If you want to do more it might be useful for you to say what you want
to do. The most probable useful answer is that you want an appropriate
library for handling jpegs that does rather more than just read it. What
libraries are available will depend on your implementation, and thus a
question with rather more information on a group related to your
implementation would probably help you more.
--
Flash Gordon
Speed <lo**********@gmail.comwrites:
Hi,
Could anyone tell me what is the simplest code to read a 8-bit
grayscale JPEG image using C.
Thanks a ton,
Speed
You will probably get about 30 replies telling you that JPEG has nothing
to do with C - and they will be right.
However, you can learn a lot by looking up the Intel developed openCV
libraries.
Here's a link to some docs which details cvLoadImage http://vision.cis.udel.edu/opencv/re...ef_highgui.htm
No need to reinvent the wheel.
"Speed" <lo**********@gmail.comwrote in message
news:11********************@z24g2000prh.googlegrou ps.com...
Hi,
Could anyone tell me what is the simplest code to read a 8-bit
grayscale JPEG image using C.
Thanks a ton,
Speed
Buy my book, Basic Algorithms. Just out. It has a chapter on JPEG
compression. Other chapters on Huffman coding, colour sopaces, and frequency
transforms lead in to it.
(Follow the link from the website).
--
Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm
"Malcolm McLean" <re*******@btinternet.comwrote:
"Speed" <lo**********@gmail.comwrote in message
news:11********************@z24g2000prh.googlegrou ps.com...
Could anyone tell me what is the simplest code to read a 8-bit
grayscale JPEG image using C.
Buy my book, Basic Algorithms.
Or rather, read Malcolm's contributions to this group and the real
experts' opinions of his expertise, and then consider whether you want
to buy his book.
Richard
On Friday 20 Jul 2007 3:25 pm, Richard Bos
<rl*@hoekstra-uitgeverij.nlwrote in message
<46****************@news.xs4all.nl>:
"Malcolm McLean" <re*******@btinternet.comwrote:
>"Speed" <lo**********@gmail.comwrote in message news:11********************@z24g2000prh.googlegro ups.com...
Could anyone tell me what is the simplest code to read a 8-bit
grayscale JPEG image using C.
>Buy my book, Basic Algorithms.
Or rather, read Malcolm's contributions to this group and the real
experts' opinions of his expertise, and then consider whether you
want to buy his book.
IIRC, his book uses his own version of BASIC, so judging it from the
perspective of his C skills is not quite fair.
santosh <sa*********@gmail.comwrote:
On Friday 20 Jul 2007 3:25 pm, Richard Bos
<rl*@hoekstra-uitgeverij.nlwrote in message
<46****************@news.xs4all.nl>:
"Malcolm McLean" <re*******@btinternet.comwrote:
"Speed" <lo**********@gmail.comwrote in message
news:11********************@z24g2000prh.googlegrou ps.com...
Could anyone tell me what is the simplest code to read a 8-bit
grayscale JPEG image using C.
Buy my book, Basic Algorithms.
Or rather, read Malcolm's contributions to this group and the real
experts' opinions of his expertise, and then consider whether you
want to buy his book.
IIRC, his book uses his own version of BASIC, so judging it from the
perspective of his C skills is not quite fair.
Possibly not, but would _you_ trust algorithms written by someone who
doesn't know the difference between an int and an integer?
Richard
[snips]
On Thu, 19 Jul 2007 21:20:02 +0100, Malcolm McLean wrote:
Buy my book, Basic Algorithms.
Or not. Let's see:
int strlen(const char *str)
You follow up your example with one that uses size_t and even explains why
you should use size_t... which raises the obvious question why include
such a badly broken example at all?
This is followed up by, among other things, strcount which counts the
number of characters in a string. Problem: it returns an int, which
you've already said, on that very page, is a bad idea, yet here you go
doing it again, apparently oblivious to the notion that the string could
just as easily be longer than the range of an int *and* be filled with a
single character.
int squnch(void *data, int len, void *out)
Er... no. Once again, a complete failure to grasp the concept of size_t
and its reason for existence. One might also ask the utility of
(len & 0xFF000000) >24; where len is an int and the code is being
compiled on a 16-bit implementation. One might *also* ask the reasoning
behind using *signed* ints for sizes; do you expect a lot of negative
length buffers to compress?
In fact, the entire example set seems to suggest a serious fetish for
using inappropriate types and inappropriate assumptions on sizes and the
like. How the hell did you get this past a reviewer or editor?
"Kelsey Bjarnason" <kb********@gmail.comwrote in message
news:5h************@spanky.localhost.net...
[snips]
On Thu, 19 Jul 2007 21:20:02 +0100, Malcolm McLean wrote:
>Buy my book, Basic Algorithms.
Or not. Let's see:
int strlen(const char *str)
You follow up your example with one that uses size_t and even explains why
you should use size_t... which raises the obvious question why include
such a badly broken example at all?
This is followed up by, among other things, strcount which counts the
number of characters in a string. Problem: it returns an int, which
you've already said, on that very page, is a bad idea, yet here you go
doing it again, apparently oblivious to the notion that the string could
just as easily be longer than the range of an int *and* be filled with a
single character.
int squnch(void *data, int len, void *out)
Er... no. Once again, a complete failure to grasp the concept of size_t
and its reason for existence. One might also ask the utility of
(len & 0xFF000000) >24; where len is an int and the code is being
compiled on a 16-bit implementation. One might *also* ask the reasoning
behind using *signed* ints for sizes; do you expect a lot of negative
length buffers to compress?
In fact, the entire example set seems to suggest a serious fetish for
using inappropriate types and inappropriate assumptions on sizes and the
like. How the hell did you get this past a reviewer or editor?
I do most of my programming on parallel hardware.
There is no interface for passing size_ts over the system. You can do so, of
course, by hardcoding in the bit size, or converting to integers, or simply
passing as a bit buffer. But that sort of thing adds complexity I don't
need.
There are good reasons for disliking size_t. That's just one of them. It
certainly isn't a case of not being able to grasp the concept. I explain,
rightly or wrongly, in the first paragraphs the coding conventions I am
using, and the justification for them.
The programs contain operations on integers, characters, and reals. I don't
want a zoo of types.
--
Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm
[snips]
On Sun, 29 Jul 2007 21:03:39 +0100, Malcolm McLean wrote:
There are good reasons for disliking size_t. That's just one of them.
Then at *most*, an unsigned type would be appropriate, unless you actually
do plan on compressing buffers with negative lengths. Using an unadorned
int is simply wrong, no matter how you look at it, for the purposes you
put it to. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: francis70 |
last post by:
Hi,
I have these 2 problem? Is there a way in Oracle to read UNCOMMITED
data. i.e. in Oracle the normal behaviour is that a user's updates to a
table are visible to other users ONLY when the...
|
by: Markus Breuer |
last post by:
I have a question about oracle commit and transactions. Following scenario:
Process A performs a single sql-INSERT into a table and commits the
transaction. Then he informs process B (ipc) to...
|
by: Steven T. Hatton |
last post by:
I know of a least one person who believes std::ifstream::read() and
std::ofstream::write() are "mistakes". They seem to do the job I want
done. What's wrong with them. This is the code I...
|
by: cnu |
last post by:
My program generates a log file for every event that happens in the program.
So, I open the file and keep it open till the end. This is how I open the
file for writing:
<CODE>
public...
|
by: Andrea Bauer |
last post by:
Hallo,
wie kann ich so eine Datei unter .Net schreiben C++ oder C#.
Bitte mit Funktionsaufrufen. Vielen Dank.
Grüße Andrea
<Product>
<ProgramNumber>2</ProgramNumber>
|
by: BBM |
last post by:
I have an object that has a fairly complex construction sequence, so I have
written a dedicated "factory" class that invokes the constructor of my object
class (which does nothing but instantiate...
|
by: Just D. |
last post by:
All!
How should we read any file from some URL? I found in MSDN the method
URLDownloadToFile function, but it's for C#. There is another example to
read but it doesn't work if the page is more...
|
by: Kai Thorsrud |
last post by:
Hi,
Thanks a lot for the short path solution to the app i'm working on by
including a Perl script ( App i'm converting from perl to .Net) for the part
i can't
do yet.
I'm communicating with a...
|
by: Jose Reckoner |
last post by:
I'm running python 2.3 on Windows XP. Anyone have a quick small script
to convert .DT1 and .DEM data to ASCII or some other format? I don't
need a viewer.
Thanks!
|
by: zl2k |
last post by:
hi, there
I have a appendable binary file of complex data structure named
data.bin created by myself. It is written in the following format:
number of Data, Data array
Suppose I have...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |