From: Kevin on 9 Jul 2010 13:22 Hi there. I'm a new MATLAB user and I'm trying to get the hang of it for a research project. Now, my task right now is to "Write a MATLAB function that will take a RGB image and return a RGB image the same as the original except that the blue component of each pixel will have the LSB set to 1." My problem is how do i convert the data for each pixel into binary? Or is this the wrong way to approach it? Keep in mind I am new to programming in general, so I would appreciate it if you could break your explanation as much as possible. Thanks in advance!
From: Walter Roberson on 9 Jul 2010 13:33 Kevin wrote: > Hi there. I'm a new MATLAB user and I'm trying to get the hang of it for > a research project. Now, my task right now is to "Write a MATLAB > function that will take a RGB image and return a RGB image the same as > the original except that the blue component of each pixel will have the > LSB set to 1." My problem is how do i convert the data for each pixel > into binary? Or is this the wrong way to approach it? Keep in mind I am > new to programming in general, so I would appreciate it if you could > break your explanation as much as possible. Thanks in advance! First you have to define the pixel representation in order to have a good idea of what the LSB of the pixel's blue channel is. In particular you have to define whether the RGB image is in floating point format or in one of the integer formats.
From: Kevin on 9 Jul 2010 14:37 Um, well, I'm just using an integer format.
From: Walter Roberson on 9 Jul 2010 14:44 Kevin wrote: > Um, well, I'm just using an integer format. Please quote context in your replies, as different people are accessing this resource in different ways, not all of which make it easy to find previous messages. To set the LSB of an integer, I suggest you investigate bitset() and bitor(). The entire routine can be written in one line (excluding the function header)
From: Ashish Uthama on 9 Jul 2010 15:26 > "Write a MATLAB function that will take a RGB image You could use the IMREAD function to get the image data into MATLAB. (I assume you are familiar with RGB images in general, and that you are 'taking' the image from a image file) Please find more details online at: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/imread.html Or please paste this in the MATLAB command window: web([docroot,'/techdoc/ref/imread.html']) This would return a 3D matrix for RGB images (more info below). > and return a RGB image That would be IMWRITE, in case you want to 'return' a physical image file. The help will show you how you can choose the type of image file you can write out to. > the same as the original except that the blue component of each pixel > will have the LSB set to 1." The links below should give you an idea how to interpret and use the matrix returned by IMREAD. Please find more details online at: http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f2-8955.html Or please paste this in the MATLAB command window: web([docroot,'/techdoc/learn_matlab/f2-8955.html']) and then, as Walter mentioned, look at BITSET/BITOR to set the LSB of the blue channel.
|
Next
|
Last
Pages: 1 2 Prev: color control Next: how to determine if the shortest distance from one point to a |