473,800 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I read a 8 bit gray image using c ?

Hi,
I am new to C programming.
Is there way to read a 8 bit gray image using C language?
Thanks and best regrads,
Raj

Mar 13 '06 #1
6 2739
guassian said:
Hi,
I am new to C programming.
Is there way to read a 8 bit gray image using C language?


Presumably the image is stored in a file of some kind, so you can open the
file using fopen, and then (only if that operation succeeded) you can read
the image data using fread. Don't forget to fclose the file when you're
done.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Mar 13 '06 #2
Thanks for the immediate reply.

Can that will give the pixels values in the matrix form?
I just want to relate the situation with the imread command
of the maltab. If you use this syntax in matlab
a=imread('tes t1.jpg');


This yields a matrix a having the dimension of the image
with the matrix element to be pixel value.
Please suggest.
Raj

Mar 13 '06 #3
guassian wrote:
Can that will give the pixels values in the matrix form?
Can what give values in the matrix form?

Please read <http://cfaj.freeshell. org/google/> before posting anything
further.
I just want to relate the situation with the imread command
of the maltab. If you use this syntax in matlab
a=imread('tes t1.jpg');


This yields a matrix a having the dimension of the image
with the matrix element to be pixel value.


There certainly is a way to achieve such functionality (otherwise it
wouldn't be available in Matlab). If you're looking for ready made code
to do that for you, you're in the wrong place (e.g., try
comp.sources.wa nted). If you're looking for hints how to decode JPEG
encoded images, you've got the wrong address again (you could try
comp.programmin g, or better yet a group dealing in graphics formats).

If, however, you give it a go first, and encounter problems that you
believe are C-specific (as in ISO Standard C), come back here, post a
minimal compilable example and a good description of your problem, and
soon enough someone will come along to help.

--
BR, Vladimir

Mar 13 '06 #4
On 2006-03-13, guassian <ra*********@gm ail.com> wrote:
Hi,
I am new to C programming.
Is there way to read a 8 bit gray image using C language?
Thanks and best regrads,
Raj


Almost certainly it will depend on the file format : they are all
different. The fact that you mention it being 8 bit and grey suggests
you then want to do something with that data.

You have fopen() to read sequence of characters. There are many
examples of fopen() available on the internet.

The formats are varied and you need to find the relevant templates if
you wish to do anything with them other than "pass on the info" or
resave under a different name (even then you must be careful with JPG
because of image compression issues if you save a JPEG save routine).

http://www.library.cornell.edu/prese.../table7-1.html

is a good start.
Good luck : there is little more fun than image manipulation in a
high/low level language as C
Mar 13 '06 #5
On 2006-03-13, Richard G. Riley <rg****@gmail.c om> wrote:

You have fopen() *and fread* to read sequence of characters. There are many
examples of fopen() available on the internet.


slight clarification.
Mar 13 '06 #6
On 2006-03-13, guassian <ra*********@gm ail.com> wrote:
Thanks for the immediate reply.

Can that will give the pixels values in the matrix form?
I just want to relate the situation with the imread command
of the maltab. If you use this syntax in matlab
a=imread('te st1.jpg');


This yields a matrix a having the dimension of the image
with the matrix element to be pixel value.
Please suggest.
Raj


You can't do it with a one-liner the way you can in Matlab.

If you need to read jpg or png files, you'll need to use libjpg or
libpng and read the docs.

Probably easier is to convert the files first to ppm, xpm or xbm (using
ImageMagick for example) and then just either write the parser yourself
in C because it will be fairly simple for these formats or find some
sources to do it.

xpm files can actually themselves be compiled as C files. Look at one
and you'll see what I mean.
Mar 13 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3648
by: Akbarr | last post by:
I'm using JAI for reading Tiff images: black and white, 1 bit depth. I want to scale them to reduce their size, but I want to do antialiasing. If I scale them as they are (using the scale operator) the images remain b/w and no antialiasing is done (I'm using bilinear interpolation). So I'm trying to convert the image to gray before scaling. But an exception raises when trying to do the ColorConvert operation, because "the number of...
0
1293
by: Graham Norman | last post by:
I am trying to create a sub image of a bufferedimage which contains a picture. I've divided the whole picture up into 80 by 80 pixels which gives me 7 rows and 6 columns. (there's a bit of wasted picture which I don't care about) Therefore each y coordinate runs from 0 to 480 in 80 increments (e.g. 7rows) The height of the area must be no less than 480+80 which is 560. When I return the height it tells me that:...
0
3539
by: Philippe Meunier | last post by:
Hi, I am using the .NET toolbar with VB.NET 2003. My toolbar uses icons images that are actually PNG files and uses alpha blending on it. So to make alpha blending work correctly with the Toolbar and the Imagelist I had to use a tricky method with API calls that is described like this by a MS MVP : 1) Use v6 of the common controls (have a manifest) 2) Load the PNG using GDI+
0
1395
by: Dana Epp | last post by:
I have a ToolBarButton that when I set it to disabled (button.Enabled = false;) causes a really ugly gray masking effect to take place. This is normal and the intended way of the button, but I would like to clean it up. Instead of using the gray mask, I want to use my own grayscaled high quality image. I thought by simply setting button.ImageIndex = new_num; (where new_num is the index of the grayscale image) I could do this. But alas, that...
0
1398
by: udir | last post by:
Hi all, I have a ToolBar on my form. Each button associated to an image from an ImageList. Why when I disable the button, the button becomes all gray ( and not grayscale image ) ? Do I have to apply a second grayscale image for each button for disable mode ?
2
2309
by: allanon76 | last post by:
I need to create an Image with more then 256 gray scale. this is my code, i've some problem setting correctly the pixel value. any idea? There is another way to create an image with more then 256 gray Bitmap myBitmap = new Bitmap(256,256,PixelFormat.Format64bppArgb); BitmapData bmd = myBitmap.LockBits(new
0
1252
by: Matteo | last post by:
Hi, i sent image byte via bt from j2me phone to c# application, after i have to create image using this code: .... byte pixels .... Bitmap bmp = new Bitmap(160, 120, PixelFormat.Format8bppIndexed);
1
3821
by: Sugan | last post by:
Hi all, I'm creating a custom button control. I need to show a color image when the button control is enabled and a gray shade of the same image when the button control is disabled. How can i convert a color image to a gray image in VB 2005. Thanks, Sugan Chennai, INDIA
2
2234
by: csharpula csharp | last post by:
Hello, I am trying to run a code which has an access to some folder that contains files and folders,the strange thing is that this folder becomes read only ,I change it before running the debugging to no read only (it and all the things it contains) but it comes to be read only again before i manipulate this folder. How comes? Thanks *** Sent via Developersdex http://www.developersdex.com ***
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9092
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.