Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm reading image...where pixel values are read as unsigned char and assigned to an unsigned int variable... when tranformed this to YUV i'm getting pixel value something like this "2046820352 -268435456" how is that negtive number represented
I'm reading image...where pixel values are read as unsigned char and assigned to an unsigned int variable... when tranformed this to YUV i'm getting pixel value something like this "2046820352 -268435456" how is that negtive number represented
You may need to use a union structure so you can decompose the value to it's components.
There are many YUV formats. You might get more info at the www.fourcc.org website.
First of all, by all means look for existing libraries that will do what you want to do with your images. Really, there's no reason for you to do what has already been done...
Assuming (for the sake of simplicity) that you know you are dealing with a 32-bit environment, then a standard int type will undoubtedly be 32 bits long. (There are predefined constants that will provide this information in a reliable and platform-independent way, but let's assume for the sake of argument that it's known to be "32.")
The most-significant bit (MSB) will be the sign-bit: 0=positive, 1=negative. This so-called two's complement notation is universally used because it eliminates the need for special rules (and therefore, special hardware designs) to handle signs. If you subtract 2 from the value $00000001 (using hexadecimal notation here...) it naturally becomes $FFFFFFFF, which is "-1." No funky hardware-designs required.
(Note: Hexadecimal notation uses the 16 digits (0-9, A-F), so that each digit represents 4 bits. Therefore, "F" represents 1111. A preceding "$," by convention, indicates to you that the number has been written in hexadecimal.)
If you declare the number to be "unsigned," then the MSB will not be interpreted as a sign-indicator. But, notice that I use the phrase, "be interpreted as." The manner in which the MSB is regarded is entirely up to you, and you must be consistent.
This is particularly true with functions like printf(), where format-string specifiers must be used to indicate that an "unsigned" output-format is to be used. There is nothing "intrinsically special" about the most-significant bit of a particular n-bit quantity: it's up to you.
Last edited by sundialsvcs; 04-07-2009 at 08:14 AM.
pixel value something like this "2046820352 -268435456" how is that negtive number represented
This is undefined behavior. It may, for example, start again from the highest value after decreasing from 0. You do not want that. It is a bug, simply.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.