Reputation: 7
I want to extract the green region (meter display) from an image. Here I have attached an image which is digital electric meter. I want to extract only the region which contains the meter reading value. If I only detect the green region then other green regions are also detected, but I want to detect only the green region which contains meter reading. How can I do that in MATLAB ?
close all;
clear all;
clc;
Im = imread('2.jpg');
Im = imresize(Im, [512 512]);
diff_im = imsubtract(Im(:,:,2),rgb2gray(Im));
figure,imshow(diff_im);
Upvotes: 0
Views: 266
Reputation: 2780
Just binarize the result:
binary = imbinarize(diff_im, 25/255); % optimal threshold would be between 22 and 25
figure,imshow(binary);
You can also play with morphological operations afterwards, e.g. morphological opening to remove leftovers of other areas.
Upvotes: 1