Prev: How to extract pixel values of a colored image into an array
Next: HDF5 low-level write: extend and append array
From: Walter Roberson on 10 Jun 2010 18:04 gavishna shah wrote: > ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message > <206a6ff9-1723-49ab-9285-deedc5adfc2c(a)z10g2000yqb.googlegroups.com>... >> fullFileName = fullfile(folder, baseFileName); > Sure,im pretty clear till this stage.After this will the following > statements work out? > array=decbin(fullFileName,16) %To get a 16 bit in each row of an > array ? fullFileName is just a string which is the _name_ of the file, whereas you probably want to work with the _content_ of the file. Re-examine the code and see where the content is read in and where it is stored. > Let A(i,j) represent the pixel in the ith row & jth colm of the image > fullFileName. The image is not the same as the filename that contains it. > Let B(i,j) be the transformed array containing bits such that > B(i,j) = 1 if (A(i,j)/2^t) mod 2 =1, where t=0,1,2,3,4,5,6,7 > = 0 otherwise Suppose for sake of argument that A(i,j) is binary 101 . Then A(i,j)/2^t mod 2 is 1 for t=0 and t=2 . That's two locations that suggest 1, and 6 (or 14) that suggest 0. Now, how are you going to combine those 8 or 16 suggestions into a _single_ storage location B(i,j) ? You also need to re-examine your assumption that A(i,j) represents the pixel in the ith row and jth column of the image. In order to be manipulating the _content_ of the image location rather than the _color number_ of the image location (an arbitrary positive index into a color table), you need to work with true color (also known as RGB) images, and those require *three* storage locations A(i,j,1), A(i,j,2), A(i,j,3) in order to specify the pixel. |