I need to eliminate row and colum of pixels

12 views (last 30 days)
this image is at color the code below make it black and white then i need to eliminate everything but keep the central numbers then i need to insert a neuron that read the remaining part and tell me what it sees(so and the end the neuron need to give me a value of "SLB9751") i thought in 2 "for" one for colums and one for row, but iam just lost
I need to eliminate row and colum of pixels in a black and white image so just the center pixels will remain, i was thinking in check for a row or colum how many pixel had if it had 1/3 of black pixel you remove it, if you have more than 2/3 of black pixel you remove it so you only keep from 1/3 to 2/3.
this is what i have:
if true
clear all
close all
clc
A = imread('placa1.jpg');
AC = A;
[r,c,p] = size(AC);
Red = 80;
Green = 80;
Blue = 80;
for r1=1:r
for c1=1:c
if AC(r1,c1,1) > Red || AC(r1,c1,2) > Green || AC(r1,c1,3) > Blue
AC(r1,c1,:)=255;
end
if AC(r1,c1,1) < Red || AC(r1,c1,2) < Green || AC(r1,c1,3) < Blue
AC(r1,c1,:)=0;
end
end
end
for r1=1:r
sum(AC,2) #now what?#
end
for c1=1:c
end
imshow(AC);
pause();
clear all
close all
clc
end
Thanks

Answers (1)

Image Analyst
Image Analyst on 3 Jun 2015
It doesn't look like you're doing that. It looks like you're setting the image values to 255 or 0. To remove rows and columns, you'd do this
image2D(rowsToDelete, :) = []; % Delete rows.
image2D(:, colsToDelete) = []; % Delete columns.
But I'm not sure why you want to crop out certain rows or columns. Why don't you attach your image and say what you want to eliminate and why, and what you really want to measure or do?
  7 Comments
Image Analyst
Image Analyst on 3 Jun 2015
Just take the green channel, threshold and call imclearborder and bwarea open
grayImage = rgbImage(:,:,2);
binaryImage = grayImage > 50;
binaryImage = imclearborder(binaryImage);
binaryImage = bwareaopen(binaryImage, 1000);
See if that works.
jorge obregon
jorge obregon on 3 Jun 2015
Edited: jorge obregon on 3 Jun 2015
iam not pretty sure how to do it, iam "new" and my teacher does not show us anything he just told us to make that u.u, and i just use what you say, but dont know if i use correctly

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!