it helps some times According to the second part of your homework you have solved it, i.e., you eliminated the shadows. For the first question: the direction can be used in many different ways. Here is the simplest way: make pretty pictures with it. A more useful reason to consider it is when you are doing non-maximum suppression, but since you are not manually doing it then there isn't much immediate use for it. To visualize the results of the gradient direction it is simply matter of establishing colors for each direction you consider. To further simplify the visualization also suppose you reduce the directions to increments of 30 degrees up to 180, starting from 0. That way if you have a direction of 35 degrees, for example, you consider it as 30 degrees (since it is the nearest one in your reduced list). Next we see an image and a visualization of its gradient direction considering Sobel and the discretization to steps of 30 degrees (black is indicating 0 degree direction).
Does the sobel mask from fspecial find horizontal or vertical edges?
around this issue You'll probably get better performance and certainly simpler code by using collectives. The first step in which your slaves send data to the master is equivalent to MPI_Gather. The step when the master sends out new data to each of the slaves is an MPI_Scatter. I think the conceptual piece that may be causing problems in your attempts so far is that MPI programs use a single program, multiple data programming model. Every rank is executing the same code but just gets different values of "rank". That seems to be understood in your blocks if (rank == master) and if (rank != master), but when using a barrier or other collective operation you have to keep in mind that no ranks in the communicator you pass to it will pass that point in the code until all the rest get there. The calls you're making to MPI_Send are blocking, so the master rank probably won't pass the first send until after the receiving rank posts a matching MPI_Recv, i.e. never because the receiving rank is stuck on the barrier.
What is the OpenCv equivalent of this Matlab code for Sobel edge detection?
seems to work fine The MATLAB implementation of the sobel edge detection isn't visible so we can only guess exactly what is happening. The only hint we get is from the documentation on edge states that when the 'sobel' option is used then