Remove Border or Pixel values of zero

hi all,
I have this image and want to remove the black outline (the dark region) , i.e I need the square region in the box
I have tried using imclearborder() and other function
hold on
for i=1:r
for j=1:c
if (impixel(g,j,i)<1)
GRAY(i,j)='delete';
end
end
end
hold off
but still have a problem..can some one help me?? please?

 Accepted Answer

Even if you do crop it, it's still tilted and you will still have black triangles at the edges, unless you straighten it with imwarp(). So, what do you want those black triangles to be? White? The mean of the gray noisy area? Some color? What exactly?

5 Comments

Karthik's answer moved here:
I want the black area to completely be removed and only the grey area should be there, some thing like the image I have attached
thanks
Can you post the original image without the white surround and annotation/caption? Also, is it okay to crop off (i.e. lose) a little bit of the tilted square to get an image with no black surround? If not, you're stuck using imwarp().
hi I have used imwrap. it is not what I need, Yes I can lose little information for getting square with no black ground
can you see in my first post there is a gray square image with black box. I wan to remove that black box. so that the image would look some thing like in the previous comment
HOW TO REMOVE THE BLACK BOX.
Well you blew your chance by ignoring my request to help you "Can you post the original image" - I'll check back sometime later. In the meantime, simply threshold, label, and call regionprops to ask for bounding box. I'll check back later to see if you posted the original image. When you force people to do things like import your annotated image into Photoshop to fix it, then often they just don't bother. That's something you should do if you want help, not us.
Karthik:
Not sure if you're still interested in my help or not. But I wrote some code to produce the image I asked you to upload from the screenshot you did upload. Then I found the black surround and cropped it. See code attached below the image it produces:

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!