Matlab- How to create network graph with various size - matlab

Hi I am interested in creating sensor nodes with various size. I have code to generate network graph. But it is not working for network size.
N=input('Enter the No. of Nodes');
G = graph(N)
If I use G=graph it displays graph where I need to plot nodes and edges manually.
But I want to create nodes and edges automatically with various size.

Related

Can active contour segment the image into different regions?

When I use the activecontour method in matlab, it seems that I can only segment the image into foreground and background, but I want to segment my MRI image into multiple regions, can I use activeconter in this case, or do I need to use other methods such as watershed?
You can start with multiple seed contours to segment multiple regions but watershed might work better depending on how much different structures are overlapping.

Increase size of individual connected component in a binary image (BW) when using regionprops

I am using imregionalmax to create a binary image BW that identifies the regional maxima in my image.
Next I want to use regionprops with property WeightedCentroid to identify the coordinates of the centroid centers in the image. However, imregionalmax returns a binary image with very small connected components, which need to be increased in dimension to enable regionprops to weigh the centroid properly.
Possible solutions:
I believe the ideal situation would be to interrupt the regionprops operation at each iteration, and simply increase the size of the current connected component that it is working with by adding a couple of pixels in height and width to it.
In case this is not possible, a work around could be to split BW into an image stack with only a single connected component in each slice, expand each component by some pixels, and run regionprops individually on each image slice. This does not seem like a efficient way of solving this though.
Is there another more efficient way, and how would I implement that?
** I am aware that one way of increasing the connected components in BW is to use imdilate, but this will lead to unconnected components becoming connected.
** Another option is to use bwmorph with property thicken, which performs very well, however in a case where multiple components are close together, the size cannot be increased in one direction and reduce the performance of WeightedCentroid.
You cannot increase measurement accuracy by extending what you want to measure...
Centroid is simply the average of all region coordinates.
WeightedCentroid only takes intensities into account in case you don't have a binary image.
If you increase your object by whatever algorithm you like you risk shifting your centroid away from its true position!

Area of intersection of connected components

I am doing a segmentation task using MATLAB. To analyze the performance of my algorithm, I need the area of intersection of each connected component in both images.
In what way are the connected components labelled in an image? Also, does PixelIdxList list all the linear indices of points that are a part of the connected component?
In what way are the connected components labelled in an image?
bwconncomp discovers the connected components by either using 4-(or 8)-connected neighborhood for 2D images or 6-(18, 26)-connected neighborhood for 3D images. Labels are enumerated starting from the left-top corner in 2D and in 3D (first slice).
Also, does PixelIdxList list all the linear indices of points that are a part of the connected component?
Yes. So, once both images are labelled, you can use intersect to find intersection between different labels. Also, you might want to read about Jaccard index.

plot large graph in matlab

I want to plot a graph with more than 5000 nodes in Matlab.
I'm using biograph and view function for this command but after some executing Matlab show this error:
The layout engine cannot generate this graph,
try other layout types or reduce the number of nodes.
I'm try other layout types but give me same error.

how to find holes in objects in matlab image?

is it possible to find holes in connected components, i.e in objects in an image. if so, can we also count holes? Like, I have used cc = bwlabel(image); to do connected components labeling. Now, how to find number of holes in each object ?
You could use the Euler characteristic. From the Matlab documentation:
The bweuler function returns the Euler number for a binary image. The Euler number is a measure of the topology of an image. It is defined as the total number of objects in the image minus the number of holes in those objects. You can use either 4- or 8-connected neighborhoods.
But be aware that a single pixel "hole" can change the Euler characteristic. You might want to use some opening/closing to smooth object outlines before using bweuler.
A hole is the presence of nothing, so you can just invert the image and then count connected components.