Re: Converting 256 level image to a 16 level image



On Jun 9, 10:29 am, ImageAnalyst <imageanal...@xxxxxxxxxxxxxx> wrote:
On Jun 8, 7:40 pm, gun...@xxxxxxxxx wrote:





On Jun 7, 4:21 am, "Roger Stafford"

<ellieandrogerxy...@xxxxxxxxxxxxxxxxxxxxxx> wrote:
"Roger Stafford" <ellieandrogerxy...@xxxxxxxxxxxxxxxxxxxxxx> wrote in
message <g2bdai$pu...@xxxxxxxxxxxxxxxxxx>...>   Good point, Walter.  If it is to be some kind of mapping, one can define a
15-element monotonically increasing mapping vector g with g(i) being the
smallest value in the range 0:255 which is to map into i and if the value is
less than g(1), it maps into 0.  Let x be an array of values, each in the range
from 0 to 255.  Then do this binary search table lookup:

 y = repmat(8,size(x));
 for k = [4,2,1,1/2]
  y = y + (2*(x>=reshape(g(y),size(x)))-1)*k;
 end
 y = y - 1/2;

Then y would be the mapping of array x into the range 0:15 in accordance
with the mapping defined by g.

-----------
  To avoid two of the reshapes, I should probably have written the binary
search above as follows.  First, make sure g is defined as a column vector.

 x2 = x(:);
 y = repmat(8,size(x2));
 for k = [4,2,1,1/2]
  y = y + (2*(x2>=g(y))-1)*k;
 end
 y = reshape(y-1/2,size(x));

Roger Stafford

Hi Roger and walter

Thanks for the replies. As I am new to this field I am having problems
in showing the image once I scale to a different level.  For example
if I run the following code,

A = imread('C:\TestData\lena.tif');
D = floor(A/16);
figure; imshow(D);

A has values upto 255 and D upto 16, but the image shown is a blank
(black) image. Is there anything else I have to do? Your help is
greatly appreciated

thanks,

Dev- Hide quoted text -

- Show quoted text -

-------------------------------------------------------------------
Dev:
It by default displays the range 0-255 since you probably have a uint8
image.  16 gray levels is so dark that it's virtually black.  Use []
as the second argument in imshow() to get it to display your 16 gray
levels with the full range of the display.
imshow(D, []);
By the way, it's a good idea to use descriptive variable names in case
someone else ever has to support your code.  For example
originalImage = imread('C:\TestData\lena.tif');
reducedGrayLevelImage = floor(originalImage / 16);
figure;
imshow(reducedGrayLevelImage , []);

Regards,
ImageAnalyst
P.S. If you see equals3D instead of the equals sign, it's because
you're using a newsreader that doesn't understand the "quoted
printable" standard for messages (like the MATLAB web-based newsread.)- Hide quoted text -

- Show quoted text -

Thanks, it works.
.



Relevant Pages

  • Re: Garmin dont want to know about bugs
    ... at a scale of 200 miles. ... display the location at all zoom levels. ... But unlike map features like POIs, highways, etc., the firmware has no ... firmware designer deciding to have them always be displayed unless the ...
    (sci.geo.satellite-nav)
  • Stephen Lebans PictureBox Class - Transparent option?
    ... I needed a run-time-manipulable image control on an Access form. ... were found on a map. ... A drawn map between 1 and 2 showing only rivers and some geographic ... I would like the white part to be transparent, that is, only display the ...
    (microsoft.public.access.forms)
  • Re: Garmin 2720 reviews?
    ... The display seemed quite good. ... The big problem I found is in the configuration of the data tabs displayed ... with the map. ...
    (sci.geo.satellite-nav)
  • Re: Glider computers - whats important?
    ... Overall I like XCSoar a little bit better now. ... XCSoar has landing sites marked in the main map, ... works with fat finger on IPAQ display, not only with pen and exact aiming, so ...
    (rec.aviation.soaring)
  • Re: Got a bit lost!
    ... can display your position on a 'map' showing you where you have been. ... Knowing where you are relative to the earlier part of your run and past runs and which direction you are travelling in can be very useful clues for getting un-lost. ...
    (uk.rec.running)