What is the result of combining equalized image with a sobel filter?
2 views (last 30 days)
Show older comments
Hi,
I was trying various things to make text stand out more in images. A hack which I came up with was by applying the sobel filter for vertical then horizontal to the rgb image then adding it an equalized version of the original image (code snippet below). However I couldn't segment or binarize the image, but it seems to make all text and well defined features darker almost as if it added some texture to the image. Please let me know if anyone knows what's going on here, im quite interested to find out whats happening.
IM=imread('image.jpg');
% Apply horizontal and vertical sobel filters:
h=fspecial('sobel');
filt=imfilter(IM,h);
filt=imfilter(filt,h');
% Equalize the image:
r=squeeze(IM(:,:,1));
g=squeeze(IM(:,:,2));
b=squeeze(IM(:,:,3));
rgb=r+g+b;
R=r./rgb;G=g./rgb;B=b./rgb;
EQ=cat(3,R,G,B);
% Resultant image seems to have amplified curves:
IMNEW= filt + EQ;
0 Comments
Accepted Answer
Image Analyst
on 3 Apr 2013
No, you're doing it all wrong. I started to try to fix your code, but it's better to just start from scratch and do it the right way from step 1. Here, try this way, using imgradient():
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
% Read in RGB image.
rgbImage=imread('onion.png');
% Display image.
subplot(3,4, 1);
imshow(rgbImage);
title('Original Color Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Display images.
subplot(3,4, 2);
imshow(redChannel);
title('Red Image', 'FontSize', fontSize);
subplot(3,4, 3);
imshow(greenChannel);
title('Green Image', 'FontSize', fontSize);
subplot(3,4, 4);
imshow(blueChannel);
title('Blue Image', 'FontSize', fontSize);
% Apply Sobel filters:
sobelFilteredImageR = imgradient(redChannel);
sobelFilteredImageG = imgradient(greenChannel);
sobelFilteredImageB = imgradient(blueChannel);
% Combine them all so we can add to original
colorSobel = cat(3, sobelFilteredImageR, sobelFilteredImageG, sobelFilteredImageB);
% Display images.
subplot(3,4, 6);
imshow(sobelFilteredImageR, []);
title('Red Sobel Image', 'FontSize', fontSize);
subplot(3,4, 7);
imshow(sobelFilteredImageG, []);
title('Green Sobel Image', 'FontSize', fontSize);
subplot(3,4, 8);
imshow(sobelFilteredImageB, []);
title('Blue Sobel Image', 'FontSize', fontSize);
% Add together with three different weightings.
weighting = 0.1;
outputImage = rgbImage + uint8(weighting * colorSobel);
subplot(3,4, 9);
imshow(outputImage);
caption = sprintf('Weighting of %.2f', weighting);
title(caption, 'FontSize', fontSize);
weighting = 0.4;
outputImage = rgbImage + uint8(weighting * colorSobel);
subplot(3,4, 10);
imshow(outputImage);
caption = sprintf('Weighting of %.2f', weighting);
title(caption, 'FontSize', fontSize);
weighting = 0.7;
outputImage = rgbImage + uint8(weighting * colorSobel);
subplot(3,4, 11);
imshow(outputImage);
caption = sprintf('Weighting of %.2f', weighting);
title(caption, 'FontSize', fontSize);
weighting = 1.0;
outputImage = rgbImage + uint8(weighting * colorSobel);
subplot(3,4, 12);
imshow(outputImage);
caption = sprintf('Weighting of %.2f', weighting);
title(caption, 'FontSize', fontSize);
3 Comments
Image Analyst
on 5 Apr 2013
Sorry I thought that's what you wanted, even though it seemed like a strange thing to do. If what you're really after is to locate road signs, you need to go here http://iris.usc.edu/Vision-Notes/bibliography/active693.html#Road%20Signs,%20Traffic%20Signs,%20Objects%20along%20the%20Road,%20Inspections to find an algorithm that works.
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!