No BSD License  

Highlights from
Grayscale Slicing

3.0

3.0 | 2 ratings Rate this file 6 Downloads (last 30 days) File Size: 430 Bytes File ID: #11901

Grayscale Slicing

by James Wilcox

 

05 Aug 2006 (Updated 10 Aug 2006)

Where you define function f of x and choose levels "a" and "b"

| Watch this File

File Information
Description

Define a function f of x and choose levels "a" and "b" such that f(x)={xmax when "a" is less than or equal to "x" less than or equal to "b" and 0 otherwise, will perform grayscale slicing.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.2 (R2006a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
11 Aug 2006 Matthew Whitaker

1) No error checking
2) Assumes an RGB input
3) Loop is totally unnecessary
The function would be more useful written something like:
function slicing(filename,a,b) % function definition
%SLICING produces a BW map of an slice of a grayscale image
% Grey scale slicing
% slicing(filename,a,b)
% f(x)= true for a<=x<=b
% = false otherwise
if b <= a
    error('Invalid Input: b <= a')
end %if

[sir,map] = imread(filename); % reading the image
              
if ndims(sir) < 3;
    if isempty(map)
        ir = sir;
    else
        ir = ind2gray(sir,map);
    end %if
else
    ir = rgb2gray(sir);
end %if

nir = false(size(ir));
nir(ir >= a & ir <= b) = true;

subplot(1,2,1),imshow(ir);
hold on;
subplot(1,2,2),imshow(nir);

15 Aug 2006 Stephen Silvis

I thought it was good

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
image analysis James Wilcox 22 Oct 2008 08:34:36
grayscale slicing James Wilcox 22 Oct 2008 08:34:36
gray scale James Wilcox 22 Oct 2008 08:34:36
slicing James Wilcox 22 Oct 2008 08:34:36
image processing James Wilcox 22 Oct 2008 08:34:36
image analys James Wilcox 22 Oct 2008 08:34:36

Contact us at files@mathworks.com