필터 지우기
필터 지우기

A grouping vector numbers

조회 수: 1 (최근 30일)
Biza Ferreira
Biza Ferreira 2014년 6월 19일
댓글: dpb 2014년 6월 19일
Hello friends I have one matrix and I need assemble all entries of a matriz in one single vector. This I've done. But I need i need extract repeated values of this and put them in new one. For this I need construct a histogram, and verify which values who not equal to zero and increment a count. So if I find a value not equal to zero I have to increment +1 to value (color) in the histogram position. with intervals100 or 200 to perform small increment in the same "color" (value) on vector
A=[1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0]
v = reshape( A.' ,1,numel(A));

답변 (2개)

dpb
dpb 2014년 6월 19일
I can't really parse the request but on an off chance it'll help...
BTW, the shortcut for reshape(x,1,[]) is
v=A(:); % this works for all array sizes to generate a column vector
Anyway, as said, taking a guess on the question...
n=histc(v,unique(v));

Biza Ferreira
Biza Ferreira 2014년 6월 19일
if true
% code
clc;
clear all;
close all;
im1=imread('imagem60.tif'); im2=imread('imagem70.tif'); imshow(im1);
im1=imresize(imfilter(im1,fspecial('gaussian',7,1.),'same','replicate'),0.5,'bicubic'); im2=imresize(imfilter(im2,fspecial('gaussian',7,1.),'same','replicate'),0.5,'bicubic');
im1=im2double(im1); im2=im2double(im2);
figure,imshow(im1),title('1?imagem original'); figure,imshow(im2);title('2?imagem original'); figure,imhist(im1),title('Histograma de im1'); figure,imhist(im2),title('Histograma de im2');
patchsize=8; gridspacing=1;
Sift1=dense_sift(im1,patchsize,gridspacing); Sift2=dense_sift(im2,patchsize,gridspacing);
% figure,imshow(showColorSIFT(Sift1)); % figure,imshow(showColorSIFT(Sift2));
SIFTflowpara.alpha=2; SIFTflowpara.d=40; SIFTflowpara.gamma=0.005; SIFTflowpara.nlevels=4; SIFTflowpara.wsize=5; SIFTflowpara.topwsize=20; SIFTflowpara.nIterations=60;
tic;[vx,vy,energylist]=SIFTflowc2f(Sift1,Sift2,SIFTflowpara);toc
Im1=im1(patchsize/2:end-patchsize/2+1,patchsize/2:end-patchsize/2+1,:); Im2=im2(patchsize/2:end-patchsize/2+1,patchsize/2:end-patchsize/2+1,:); warpI2=warpImage(Im2,vx,vy); figure,imshow(Im1), title('imagem Im1'); figure,imshow(warpI2),title('warpImage Im2');
% display flow clear flow; flow(:,:,1)=vx; flow(:,:,2)=vy; figure,imshow(flowToColor(flow)),title('diferenca entre as duas imagens');
dstPath='output/';
Amp=sqrt((vx).^2+(vy).^2); figure,imshow(Amp,[]);
direction=atan(vy./vx); figure,imshow(direction,[]);
a=hist(direction,50) end
I just need read this direction variable and verify all values different zero, and when the value repeat i increment 1 more in value scale. exemple: A=[1 1 1 1 1 1 1; 2 2 2 2 2 2 0]; in histogram the value 1 repeat seven time so the amplitude should be 7 for the value 1, for value 2 should be 6, to 0 1 ...
  댓글 수: 1
dpb
dpb 2014년 6월 19일
Did you not try the previous response???? That's precisely what it returns.

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

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by