clc; close all; clear all; I = imread('uma.png'); subplot(3,2,1); imshow(I); title('Original'); % ------------------Check its size-------------------------------------------------- [x y]=size(I) % ----------------Grayed image----------------------------------------------------- gray = rgb2gray(I); subplot(3,2,2);imshow(gray); title('Gray image'); % Histogram Plotting subplot(3,2,3);imhist(gray,64); title('Histogram'); % Thresholding an image T=20; cnt = 0; x =0;y=0; for i = 1:1:x+1 for j = 1:1:y+1 { if {gray(i,j)=<t;> gray(i,j)=0; cnt= cnt+1; } else{ gray(i,j)=255; } end end end figure; imshow(gray); OR % Thresholding an image T =20; c=zeros(size(gray)); [r c1] = size(gray); allpix=gray(r, c1); for i=1:r for j=1:c1 if allpix(i,j)> T c=255; else c=0; end end end figure, imshow(c);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)