MATLAB Answers

hello i need clearer circle after performing the below code help me plz

조회 수: 6(최근 30일)
shivu shetty
shivu shetty 2 Apr 2018
편집: John BG 11 Apr 2018
clear all
close all
[FileName,PathName] = uigetfile('*.*','Select the image file');
%dilate image
SE = strel('line',1,1);
H = imdilate(H,SE);
S = imdilate(S,SE);
V = imdilate(V,SE);
%performing dwt2 on h,s,v channels
[hca1,hch1,hcv1,hcd1] = dwt2(H,'bior1.3');
[sca1,sch1,scv1,scd1] = dwt2(S,'bior1.3');
[vca1,vch1,vcv1,vcd1] = dwt2(V,'bior1.3');
%replacing ll(hac1) with adding all other three values(hch1,hcv1,hcd1). sililarly for s and v channls ll band is replaed with new value
reconstructing image using replaced ll value
%combing all the three result into hsv1 image for display
title('reconstructed HSV image');
title('reconstructed rgb image');
%perfotming otsu
level = graythresh(grayimg);
BW = im2bw(grayimg,level);

  댓글 수: 0

댓글을 달려면 로그인하십시오.

채택된 답변

John BG
John BG 9 Apr 2018
편집: John BG 10 Apr 2018
Hi Shivu Shetty
to acquire center and surface points on the image, use the attached ginputRed.m that has red crosshairs, as the standard ginput.m does not allow to change color, and there is no switch in figure, axes or plot handles to change crosshair color.
More images uploaded as soon as 10 uploads per day cap reloaded.
acquiring one of your start images:
clear all;close all;clc
A1=A(:,:,1); % A2=A(:,:,2);A3=A(:,:,3);
% 002
adjusting contrast
% 003
trying surf
% 004-1
surf has all rings clipping the roof of 255, which is good to count tree rings.
surf(255-A02) better than surf(A02)
yet one wonders if the rings could be a bit thicker to count them and if it is possible to have all rings with the highest amplitude, to avoid false counts, or missing rings
trying interpolation in case there's need for more samples
some ring peaks look too sharp with only one sample and many rings do really have a low level:
% 005
% 006
no discernible difference, still some peaks to sharp, some other peaks too low
let's carry on with fence-like rings as peaks, better than narrow trenches in A02
% 004-2
there are some really low yet valid peaks too close to false peaks
trying single straight cross section, centre to outer crust
ax4.DataAspectRatio=[1 6 1]
ax4.DataAspectRatio=[1 1 1]
campos(ax4,[250 250 3664])
how to fix ginput figure axes and plot handles not having switch for crosshair colour:
hold(ax4,'on');plot(ax4,nx,ny,'r-');plot(ax4,[p(1,1) p(2,1)],[p(1,2) p(2,2)],'ro')
% 007
for k=1:1:numel(nx)
L=[L A1(ny(k),nx(k))]
figure(5);plot(L);grid on
figure(6);plot(diff(L));grid on
cross sections shown in 005 and 006 above
it still doesn't get the count to the comfortable place where rings are clear tall peaks and everything else far enough below to avoid confusion.
Yet, surf has coloured the rings clearly yellow, away to everything else in magenta, let's exploit this
Isolating yellow pixels
close all;clear all;clc
% 008
A13=A20(:,:,1)-A20(:,:,3); % A23=A20(:,:,2)-A20(:,:,3);
% figure(2);imshow(A)
% 008
% ax1.DataAspectRatio=[9 9 1]
% axis(ax1,[791 1352 732 1201])
axis(ax1,[325 684 349 686])
the previous was marking ring pixels red, just to make sure marking the right pixels
solving the too short peaks, we need tall peaks against everything else for such purpose let's binarize
% BW better contrast
for k=1:1:numel(x13)
% axis(ax2,[791 1352 732 1201])
axis(ax2,[325 684 349 686])
% 009
Now let's use flexible cross section, let's zig-zag, no need to count rings while pulling the cross section line,
but let's make sure that each straight section of cross section clearly gets one or more tree ring and if not just for clarity, that new sections start in between cross sections
n=[p2(1,1) p2(1,2)];
for k=1:1:size(p2,1)-1
n=[n;nx_section' ny_section'];
plot(ax2,[p2(1,1) p2(end,1)],[p2(1,2) p2(end,2)],'ro','LineWidth',4);
% 010
variable peaks of interest amplitude solved, now all rings are 1s, and all space between rings are 0s
for s=1:1:size(n,1)
L=[L B(n(s,2),n(s,1))];
mind the gap attempting the reading loop with B(n(s,1),n(s,2)) a result that looks ok is reached but neither the amount of rings nor the initial values of the cross section are correct.
figure(3);plot(L','r','LineWidth',3);grid on
% 011
counting peaks
pks =
Columns 1 through 9
1 1 1 1 1 1 1 1 1
Columns 10 through 17
1 1 1 1 1 1 1 1
locs =
Columns 1 through 9
60 118 165 210 260 297 319 338 364
Columns 10 through 17
375 382 397 411 421 434 442 453
And the result is:
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance for time and attention
John BG

  댓글 수: 3

John BG
John BG 10 Apr 2018
I am having a look at the 1st picture tree trunk cross section you posted, the one with both dark and bright core background, and with a really high density of rings on the outer layers.
1.- would it be possible to take a photo with higher resolution?
your attached photo is 118kB, my screen shot of that photo is 128kB
now look
It would greatly help precisely with the many tight rings that pile up on the surface of the tree, to have at least 2 pixels per ring, one pixel for the ring, and next pixel for the gap between rings.
not enough water during last years? higher temperatures? excessive pruning? it doesn't matter, the photo with the current resolution doesn't allow to discern.
Since now there's not even 1 pixels, or up to 1 pixel per ring, can you double, at least double the resolution of your start photo?
If so is possible, please post the enhanced resolution and I will have a look, ok?
If you think that it would be ok to just consider all that outer bunch of layers as 1 thick layer, and you are ok with the counting of the remaining, please let me know, right?
John BG
shivu shetty
shivu shetty 11 Apr 2018
i dont have high resolution images. is there any other way to count those rings?
John BG
John BG 11 Apr 2018
the narrowest case where we can tell that there's ring is when
'.. 101010101 ..'
how can one tell there's a ring if the very first data we get hands on is:
' .. 111111 ..'
The answer is, we cannot tell, at least not with such low amount of data.
No matter how smart a worker is, if the boss asks a worker to guess data, there are 6 possible ways for a worker to address such difficult query:
1.- Gamble one's job on the line by supplying an answer where there's only way for guessing.
Not recommended.
2.- Have a go and try your boss gambling his / her job by asking for a pair of dice, signed and approved, so when the hoax hits the fan, you can bring forward evidence that the decision to gamble was your boss's not yours.
3.- Convince some one else to take the hit for you, But again not recommended, because the worker is trying to do what the boss did to the worker.
The chances are the whoever the worker (you) find(s), the boss will have arranged in advance to pretend to help you.
But right before the critical moment of bringing forward evidence to the boss of the boss, everyone will suddenly point at you, and the mob will recklessly push the worker under the train.
It's a Microsoft world, we only live in it:The boss can always read your emails, you can't read the boss emails unless he/she wants to or pretends to.
4.- Convince your boss to give you a better camera, with more pixels in the CCD so you can get at least get
' .. 1010101 ..'
across the narrowest cross section. This is a common practice in huge budget projects: when not sure delay, spend more time and resources hopping that somehow a solution will fall down from a tree branch, like Newton's apple, needless to recall that such story was popular fiction that ended up in the books: Newton based his initial studies dropping apples 'from shoulders of giants' meaning from the roofs of high buildings with known heights.
5.- Bring in your own far better camera, that you have purchased with your own money, with the best of intentions.
I once did this one, in Spain for the contractor of a mobile operator that told me to assess base stations and told me to use my own camera when I asked for a company camera:
After solving the technical problem I almost end up having to leave my camera in the premises when the bad boss had a go on 'health & safety' and 'company regulations'.
Then is when the Union comes in really really handy.
Never ever do this in security jobs, especially if you have signed down compliance to any kind of government act.
6.- Tell boss to do it him/herself. Or tell the boss of the boss that the boss is an incompetent.
In either situation it's worth having the hand ready on the eject handle, and be certain you did all the pre-flight checks that included parachute, map, compass, knife, rations, .. in case one has to walk to next job.
John BG

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Image Analyst
Image Analyst 8 Apr 2018
Contact the Laboratory of Tree Ring Research at the University of Arizona. They started the field and are probably still the world's leader. They can probably point you to their best publications. You might even be able to obtain code from them.

  댓글 수: 0

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by