Barlow points and Gauss points - post-processing

Are all Gauss points (integration points) also Barlow points (optimal locations to extract stresses during post-processing stage)? I am guessing no. Only for some very specific elements this might be true. If not, do any commercial FEM codes use Barlow points instead of Gauss points to extract stresses?

Related

Calculating geodesic distance in MATLAB

I want to calculate geodesic distance between non-adjacent nodes in an directed graph. As in the following matrix (W), zeros reperesent that those nodes are non-adjacent and other values show weights of the edges corresponding nodes. I calculated the distance according to the following equation:
I used the MATLAB function graphshortestpath(). However, I'm afraid this function couldn't provide what I am looking for. So the question is what is another way to calculate such a distance? Is there another function in MATLAB for that? Is it possible that making the matrix sparse affects final result?
Program code:
N=6; % Size of matrix W
W=[0,0.797944993710195,0,0,0,0;0.495326358306295,0,0.164911895411107,0,0,0;0,0.0530273831645896,0,0.00901073533222818,0,0;0,0,0.00709165683115063,0,0.438584093809830,0;0,0,0,0.397895339311598,0,0.000916573989905329;0,0,0,0,0.00104307323830613,0]; %Connectivity matrix
Geo_dist=zeros(N); %temporary variable for geodesic distance measurement
W_sparse=sparse(W); %Making W sparse because the matlab function works only with sparse matrix
for g=1:N
for h=1:N
if W(g,h)==0 & g~=h;
Geo_dist(g,h)=graphshortestpath(W_sparse,g,h,'directed',false);
end
end
end
Can you use bwdistgeodesic or graydist in the Image Processing Toolbox directly on the image grid?
https://www.mathworks.com/help/images/ref/graydist.html
https://www.mathworks.com/help/images/ref/bwdistgeodesic.html
Or if you prefer something smoother, imsegfmm will let you use fast marching method to compute the geodesic distance if you look at the doc example:
https://www.mathworks.com/help/images/ref/imsegfmm.html
I'm assuming in my response that you have gridded image data and that this isn't a graph of arbitrary connectivity since this is tagged "image-processing".

How to compute distance and estimate quality of heterogeneous grids in Matlab?

I want to evaluate the grid quality where all coordinates differ in the real case.
Signal is of a ECG signal where average life-time is 75 years.
My task is to evaluate its age at the moment of measurement, which is an inverse problem.
I think 2D approximation of the 3D case is hard (done here by Abo-Zahhad) with with 3-leads (2 on chest and one at left leg - MIT-BIT arrhythmia database):
where f is a piecewise continuous function in R^2, \epsilon is the error matrix and A is a 2D matrix.
Now, I evaluate the average grid distance in x-axis (time) and average grid distance in y-axis (energy).
I think this can be done by Matlab's Image Analysis toolbox.
However, I am not sure how complete the toolbox's approaches are.
I think a transform approach must be used in the setting of uneven and noncontinuous grids. One approach is exact linear time euclidean distance transforms of grid line sampled shapes by Joakim Lindblad et all.
The method presents a distance transform (DT) which assigns to each image point its smallest distance to a selected subset of image points.
This kind of approach is often a basis of algorithms for many methods in image analysis.
I tested unsuccessfully the case with bwdist (Distance transform of binary image) with chessboard (returns empty square matrix), cityblock, euclidean and quasi-euclidean where the last three options return full matrix.
Another pseudocode
% https://stackoverflow.com/a/29956008/54964
%// retrieve picture
imgRGB = imread('dummy.png');
%// detect lines
imgHSV = rgb2hsv(imgRGB);
BW = (imgHSV(:,:,3) < 1);
BW = imclose(imclose(BW, strel('line',40,0)), strel('line',10,90));
%// clear those masked pixels by setting them to background white color
imgRGB2 = imgRGB;
imgRGB2(repmat(BW,[1 1 3])) = 255;
%// show extracted signal
imshow(imgRGB2)
where I think the approach will not work here because the grids are not necessarily continuous and not necessary ideal.
pdist based on the Lumbreras' answer
In the real examples, all coordinates differ such that pdist hamming and jaccard are always 1 with real data.
The options euclidean, cytoblock, minkowski, chebychev, mahalanobis, cosine, correlation, and spearman offer some descriptions of the data.
However, these options make me now little sense in such full matrices.
I want to estimate how long the signal can live.
Sources
J. Müller, and S. Siltanen. Linear and nonlinear inverse problems with practical applications.
EIT with the D-bar method: discontinuous heart-and-lungs phantom. http://wiki.helsinki.fi/display/mathstatHenkilokunta/EIT+with+the+D-bar+method%3A+discontinuous+heart-and-lungs+phantom Visited 29-Feb 2016.
There is a function in Matlab defined as pdist which computes the pairwisedistance between all row elements in a matrix and enables you to choose the type of distance you want to use (Euclidean, cityblock, correlation). Are you after something like this? Not sure I understood your question!
cheers!
Simply, do not do it in the post-processing. Those artifacts of the body can be about about raster images, about the viewer and/or ... Do quality assurance in the signal generation/processing step.
It is much easier to evaluate the original signal than its views.

What is the simplest way for ploting a TSP graph in matlab?

I have created a very simple Traveling Salesman Problem`s algorithm and now I need to output the results in a visual garph.
I have a matrix with path weights and an correctly ordered array of points (the path)
The Internet is full of very complex and detailed examples of TSP (like for DNA research) yet I am looking for some basic plotting function.
Not exactly sure what you want to plot, but assuming it is just the resulting path it is quite simple:
x=randperm(10); % Your x coordinates
y=randperm(10); % Your y coordinates
% Now plot these points and make sure you add 1 term to return to the starting point
plot([x x(1)],[y y(1)])

Finding 2d impulse peaks in MATLAB

What is the best method for finding impulse peaks (dirac delta) in a 2d matrix.
More specifically, I would like to find the harmonic frequencies of a given image and so I need to find impulse peaks in the image absolute value DFT.
I thought of using findpeaks but there's no 2d version. I also saw earlier posts regarding finding ordinary peaks using imdilate and/or imextendedmax but those find all the peaks in a 2d matrix whereas I am only interested in impulse peaks. I am sure DSP people have a common recipe for this...
Please Help,
Thanks
What you want to do is find peaks with high contrast. Thus, you need a way to identify local maxima, plus a way to measure the difference between the peak and the surrounding values. Thresholding on this difference will identify the impulse peaks for you.
Assuming your input signal is called signal
%# dilate to find, for every pixel, the maximum of its neighbors
dilationMask = ones(3);
dilationMask(5) = 0;
dilSignal = imdilate(signal, dilationMask);
%# find all peaks
%# peaks = signal > dilSignal;
%# find large peaks peaks by thresholding, i.e. you accept a peak only
%# if it's more than 'threshold' higher than its neighbors
peaks = (signal - dilSignal) > threshold;
peaks is a logical array with 1's wherever there is a good peak. You can use it to read peak heights from signal with signal(peaks), and to find coordinates using find(peaks).
This paper I wrote contains Matlab source code for fast local peak detection in 2D. It works similar to imregionalmax() in Mathworks Image Processing Toolbox but allows you to specify a local neighborhood radius: bigger radius -> sparser peaks.
Since you expect sparse impulses, the nonmaxsupp_scanline() function may be suitable for you.
The findpeaks algorithm is pretty trivial; if an element is bigger than both its neighbours, then it is a peak. Writing a 2D version of this should be pretty simple.

How do I do numerical integration of a vector in MATLAB?

I have a vector of 358 numbers. I'd like to make a numerical integration of this vector, but I don't know the function of this one.
I found that we can use trapz or quad, but i don't really understand how to integrate without the function.
If you know the horizontal spacing of your vector, you can use trapz in order to integrate it without the function. For example, to integrate y=sin(x) from 0 to pi with 358 sections,
x=0:pi/357:pi;
y=sin(x);
area=trapz(x,y);
If you just use trapz(y), you'll get a much larger number, since the default distance between points is assumed to be 1. This problem can be fixed by multiplying by the distance between x points:
area=pi/357*trapz(y);
You don't need to know the function in order to numerically integrate; that's the point of trapz and quad. Just pass trapz your vector. Here's a link to the documentation.
Think about integration as to find area under the curve, which is formed by your vector. Well it's not actually a curve, but polygonal chain. What TRAPZ function is doing, it finds sum of areas of each trapezoids formed by every two neighbor points in your vector and their projection on X axis. See the function documentation, if you have uneven distance between your points or if distance not equal one.
You can read more about this method, for example, on Wikipedia.