How to fix the edges in the image

100 views Asked by At

I have got a result as shown in the following image. As you can see, there are some edges which are not all straight. I want this image to be similar to this one (I'm not sure why the grey shade appears. Maybe because I manually extracted it?). But, the main thing here is to be similar to the white edges. I tried using morphological operations, but with not much improvements.

Any ideas how to fix this issue?

Thanks.

1

There are 1 answers

2
Bruce Dean On

I loaded your data into a variable called "toBeSolved."

rawData1 = importdata('to be solved.JPG');
[~,name] = fileparts('to be solved.JPG');
newData1.(genvarname(name)) = rawData1;
% Create new variables in the base workspace from those fields.
vars = fieldnames(newData1);
for i = 1:length(vars)
    assignin('base', vars{i}, newData1.(vars{i}));
end

Now this is an indexed image so there are 3 frames, as can be seen from:

>> size(toBeSolved)
ans =
   452   440     3

The data content of each frame appears to be identical, so maybe all you care about is the grayscale information from 1-frame? If thats the case lets just take the first frame:

data1 = im2double(toBeSolved(:,:,1)); 

And then normalize the data to the max value in the image:

data1 = data1 / max(data1(:));

Now take a look at a mesh view and we see that, as expected, there is significant noise and corruption around the edges:

enter image description here

The appearance about the edges suggests trying a thresholding operation to the data. I experimented with the threshold value and found that 0.13 produces some improvement:

data2 = double(data1 > 0.13);

which gives:

enter image description here

or the grayscale, imshow(data2):

enter image description here

I don't know if this is acceptable to your application, the edges are not perfect, but it does seem improved over what you started with.

By the way, I checked out your "solved" data as well and that appears to also have the same underlying level of noise and edge defects as the "toBeSolved" file, but at least visually, the corruption in that image is harder to see duo to the gray-scale values around the edges.