Decreasing graylevels of image using certain interval

Hi,
How can i decrease the 255 gray level of image to 17 graylevels such that
-7 to +7 considered as gray level "0"
8 to 23 as "16"
24 to 39 as "32" and so on.. upto to 255.
pls help, thanks in advance...

답변 (2개)

mark
mark 2013년 11월 28일
편집: mark 2013년 11월 28일

0 개 추천

I'd actually be interested in this too as I am currently using imagesc(X) for plotting stuff.
I found that if you go to the figure editor and right click on the colorbar, you can manually adjust it by scrolling on the bar. But, as with anything you edit post-process you need to do it every time.
Image Analyst
Image Analyst 2013년 11월 28일
Try this:
lut(1:8) = 0;
lut(8:23) = 16;
lut(24:39) = 32;
% and so on....
% To convert
outImage = intlut(inputImage, lut);

댓글 수: 4

Or you can use imquantize().
thanks for idea..
i tried it as
I= imread('image.jpg');
LUT(1:8) = 0;
LUT(8:23) = 16;
LUT(24:39) = 32;
LUT(40:55) = 48;
LUT(56:71) = 64;
LUT(72:87) = 80;
LUT(88:103) = 96;
LUT(104:119) = 112;
LUT(120:135) = 128;
LUT(136:151) = 144;
LUT(152:167) = 160;
LUT(168:183) = 176;
LUT(184:199) = 192;
LUT(200:215) = 208;
LUT(216:231) = 224;
LUT(232:247) = 240;
LUT(248:255) = 255;
% To convert
B = intlut(I, LUT);
imshow(B);
but the error seems as "Unexpected MATLAB expression" and am using matlab R2010a. Does it support "intlut" function??
It's in the Image Processing Toolbox. Do you have that? If you don't you can do it manually with one or more for loops.
You had mistakes in your code. LUT wasn't uint8 and didn't have 256 elements. Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
% Read in standard demo image;
grayImage = imread('cameraman.tif');
% Display the original gray scale image.
subplot(1, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
LUT(1:8) = 0;
LUT(8:23) = 16;
LUT(24:39) = 32;
LUT(40:55) = 48;
LUT(56:71) = 64;
LUT(72:87) = 80;
LUT(88:103) = 96;
LUT(104:119) = 112;
LUT(120:135) = 128;
LUT(136:151) = 144;
LUT(152:167) = 160;
LUT(168:183) = 176;
LUT(184:199) = 192;
LUT(200:215) = 208;
LUT(216:231) = 224;
LUT(232:247) = 240;
LUT(248:256) = 255;
LUT = uint8(LUT);
% To convert
quantizedImage = intlut(grayImage, LUT);
% Display the original gray scale image.
subplot(1, 2, 2);
imshow(quantizedImage, []);
title('Quantized Image', 'FontSize', fontSize);

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기

질문:

2013년 11월 28일

댓글:

2013년 11월 30일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by