I am trying to obtain the pixel values as and when I move my mouse cursor in Maltab .Can I use g-input function in Matlab? I am not getting how to proceed. All the pixel values are doubles.
Does impixelinfo do what you need? This requires Image Processing Toolbox.
Alternatively, can you just use a Data Cursor? For example, type image to display a default image. Then in the figure toolbar, click the Data Cursor button (looks like a little yellow square and a blue line, with a black crosshair). Finally click on a pixel in the image to display X and Y coordinates, and RGB values of the pixel. You can pick the data cursor up with the mouse and move it around to display other pixels.
Related
For example, if I were to use the following code for a photo in my MATLAB path:
imtool('Vision.bmp')
the following figure would load:
MATLAB Image with Pixel Coordinates in Bottom Left Corner
Based on where I hover my mouse on this image, the pixel coordinates in the bottom left corner change. I want to be able to extract the coordinates from this image and store them in a matrix, so that later on I can extract the same data - from the image I specified - using this newly created matrix.
Fair warning, I've just started to learn to code.
When I open a Dicom image on Matlab (R2014b) and place the data cursor on a specific set of coordinates, I obtain an "index" (or pixel value) that does not match the same set of coordinates on the image's matrix (T).
>> figure, imshow(T);
See below on attached image.
Any idea why this is happening?
When using images, the data cursor tool with MATLAB's figure and its various ilk assume that X and Y are the column (horizontal) and row (vertical) coordinates respectively. In the variable inspector (the left part of your figure), these are reversed.
Be careful when using the data cursor on images. See this post by MathWorks on more details regarding interactive display of data: http://www.mathworks.com/help/matlab/creating_plots/data-cursor-displaying-data-values-interactively.html
I have searched the internet for a solution to the question above but have had no luck up to now. I have been producing a number of 2D plots where the origin of (0,0 point) is represented by an image. I have made these by plotting the data on an image, where the image is all white apart from the desired symbol at the center point (so I can reshape it as needed). I then move the axis so they cross at the center point. This all works fine, but I now have to create a number of plots using ‘fill’ to place two shaded areas on the plot that overlap in the center. This causes the symbol to be difficult to see even using ‘alpha’.
I therefore have two options to get the desired effect, both requiring me to put an image on top of the figure after the data is plotted. These options are:
1) I place the image on top of the plot and apply alpha to it (May not look very good as it will mute the plot).
2) The better option would be to crop the image around the symbol and then position it on top of the plot so the image center is at the origin (I have no idea how to position the image this way).
Both methods need the image to be placed on top of the plot after the data is plotted. I have tried 'hold on' and calling 'figure(imagesc(Image))' neither work. I have Matlab 2012b but no toolboxes (so cannot use subimage etc.)
Thanks for any help you can give
You can set the transparency of individual pixels of an image using the 'AlphaData' option. So, you can plot the overlay as follows:
% plot your data normally
...
hold on
% assuming the overlay is a 11x11 image
image(-5:5,-5:5,image_matrix,'AlphaData',alpha_matrix);
image_matrix would obviously be the matrix with your image data stored in it, while alpha_matrix would be a matrix of the same size as image_matrix. Every pixel you want to show would have a value of 1, every pixel you want to hide (the white pixels) would be 0.
My image is a 2D surface of a protein, and I use matlab function "scatter" to display the image, so there are some white empty spaces in it.
I want to fill them with colors,but the question is that the points have different colors, some are red and some are orange(point color is decided by its RGB value).
So I wanna assign the color of the white space similar to their corresponding neighbors.
the original work i did is to extract the edge of the polygon first,which helps me detect if the point is inside the polygon or not, because I am not assigning colors to white spaces that are outside the polygon.
And then simply scan the whole image pixels one by one to check if the pixel is the white, if so, I just assign the neighbor color to it,like what i said, I have to check if the pixel is inside the polygon or not every time.
But the speed is really slow, and the result is not good enough,could anybody give me some idea on it ?
I have the 2D scatter points image and also the 3D structure.Each point in 2D can find one
counterpart in 3D, I don't know if this information would help.
After an erosion with a disk kernel(7x7) such as and then a bilateral filter:
PS: if you have the 3D points structure, upload it somewhere and post a link
It's from Stack Overflow question How do I calculate the area under a curve in an image with MATLAB?, but I'm also interested in this.
How do I filter out pixels not in the green channel?
And how do I select a point which is inside a closed box with MATLAB?
Alt text http://internationalpropertiesregistry.com/Server/showFile.php?file=%2FUpload%2Fstatistics.gifc49ca28823a561a41d09ef9adbb5e0c5.gif
For your two questions:
Colored pixels have red, green, and blue color components. Selecting pixels based on their color involves selecting how much of each RGB component is present in the pixel. For example, a pure white pixel has each color component at its maximum (1 if the image type is double precision, 255 if the image type is uint8). You can look at my solution to the referenced question to see one way you can select pixels based on their RGB components. You can also check out this MATLAB documentation for more information about images and their data types.
One way to select a point is to let the user select it using the GINPUT function. For example, the following will let the user select 1 point from the current axes, returning the x and y coordinates where they click:
[x,y] = ginput(1);
For the first question, #gnovice's answer should suffice.
For the second question: Use a Monte Carlo approach: have the algorithm choose a random pixel using RANDI (you may want to search within, say, 20 pixels of the center of the image to avoid problems with the border). If it's a green pixel, you try again. If it's a white pixel, you are inside one of the squares.