How to change the histogram colour in Matlab - matlab

So i'm awful at Matlab and I mainly learn through examples and literally spelt out explanations.
So baring that in mind - Right now i'm trying to find how likely it is that one image i'm given is in anther via a histogram.
What i want to do is create 3 histograms for red, blue & green for each image and then add those into one image - So basically i'll have an image with a literal green histogram showing the green, a red one showing the red and a blue one showing the blue.
I know that to show a colour chanel in matlab i have to do imhist(image(:,:,1/2/3)
however that still gives me a histogram in blue.
I've looked up some things that are meant to help with this issue but it's normally aimed toward someone who knows what they're doing.... not helpful.
I've heard peope saying something like get(get(gca,'child')) which just seems giberish to me.
SO - for what i'm trying to do, image detection via histrograms, is this an appropriate method? And if so HOW do i create my 1 histogram that shows all 3 histograms in their respective colour
Cheers

You could use this version of imhist:
[counts,x] = imhist(...)
And then draw your histograms yourself, via bar, stem or similar.
These functions are then fully customizable and you can plug in your favourite color, linestyle, etc.

Related

matlab: bar, how to change the edge color?

I am having trouble to change the bar color, I want it to be white in the middle, and red at the edge. Looking at matlab's description
if I do:
bar(y,'FaceColor','w','EdgeColor','r','LineWidth',1)
It should give me the above. However, when I actually run it, it only give me white graph.
Update: my y is:
y=zeros(1,5000); y(3000)=1; y(4000)=1;
Using the above, I got....
With so many bars, Matlab probably has trouble differentiating edge ('EdgeColor') and fill ('FaceColor') of each. After all, each complete bar is less than a screen pixel.
I suggest you use white edge and colored fill. That works for me. It's as if 'FaceColor' had precedence over 'EdgeColor'.
bar(y,'FaceColor','r','EdgeColor','w','LineWidth',1)
Or better yet: replace each bar by a line, that is, use stem:
stem(y,'r','marker','none')

Extract Rectangular Image from Scanned Image

I have scanned copies of currency notes from which I need to extract only the rectangular notes.
Although the scanned copies have a very blank background, the note itself can be rotated or aligned correctly. I'm using matlab.
Example input:
Example output:
I have tried using thresholding and canny/sobel edge detection to no avail.
I also tried the solution given here but it detects the entire image for cropping and it would not work for rotated images.
PS: My primary objective is to determine the denomination of the currency. There are a couple of methods I thought I could use:
Color based, since all currency notes have varying primary colors.
The advantage of this method is that it's independent of the
rotation or scale of the input image.
Detect the small black triangle on the lower left corner of the note. This shape is unique
for each denomination.
Calculating the difference between 2 images. Since this is a small project, all input images will be of the same dpi and resolution and hence, once aligned, the difference between the input and the true images can give a rough estimate.
Which method do you think is the most viable?
It seems you are further advanced than you looked (seeing you comments) which is good! Im going to show you more or less the way you can go to solve you problem, however im not posting the whole code, just the important parts.
You have an image quite cropped and segmented. First you need to ensure that your image is without holes. So fill them!
Iinv=I==0; % you want 1 in money, 0 in not-money;
Ifill=imfill(Iinv,8,'holes'); % Fill holes
After that, you want to get only the boundary of the image:
Iedge=edge(Ifill);
And in the end you want to get the corners of that square:
C=corner(Iedge);
Now that you have 4 corners, you should be able to know the angle of this rotated "square". Once you get it do:
Irotate=imrotate(Icroped,angle);
Once here you may want to crop it again to end up just with the money! (aaah money always as an objective!)
Hope this helps!

visualising l*a*b space values in matlab or any software

I have table of l,a,b values and want to visualise these colors in matlab (or any other suitable software). Is there any quick way like series of rectangles filled with color values from the table?
There are several versions of the Lab color space, but presumably you're referring to most common, CIELAB. You can use imwrite in Matlab to create a TIFF image with 'cielab' specified for the 'Colorspace' option. I wouldn't trust Matlab as a viewer for the resultant images though. Photoshop in lab mode (from the menu bar: Image > Mode > Lab Color) would be a good choice if you want work with and see the closest thing to the actual CIELAB space. Other viewers/editors may convert to RGB or CMYK before rendering to the screen (likely without warning you), but maybe you don't mind. If you just want to convert from CIELAB to RGB, you might find these functions useful.
After lots of research, I found out there is a plugin called 'color inspector' that can be used along with ImageJ (all opensource tools). Have excellent capacity to view and analyse different color space. Even it has some color tools that matlab yet to have. here is imageJ: http://rsbweb.nih.gov/ij/download.html
and the plugin
http://rsb.info.nih.gov/ij/plugins/color-inspector.html
Hope this is useful to someone

how to make stacked bar graph readable in white and black only

I have a stacked bar graph to include in my paper, which is going to be printed by reviewers in black and white only. When I print it out, I cannot tell the difference between some parts of it, which would otherwise be clearly distinguishable in color. Is there any way to make it readable even in black and white? Thanks in advance.
Have a look at the function presented in this File Exchange Pick of the Week to create hatched patterns instead of (or in addition to) your colors.
Here's one example:
Here's one example of how to use applyhatch_pluscolor:
figure, bar(rand(3,4)
[im_hatch,colorlist] = applyhatch_pluscolor(1,'|-.x',1,[1 0 1 1]);

How to convert a black and white photo that was originally colored, back to its original color?

I've converted a colored photo to black and white, and bolded the edges. Now i need to convert it back to its original color with the bolded edges. Is there any function in matlab which allows me to do so?
Once you remove the colour from an image, there is no possible way to automatically put it back. You're basically reducing a set of 16,777,216 colours to a set of 256 - on average each shade of grey has 65,536 equivalent colours, and without the original image there's no way to guess which it could be.
Now, if you were to take the bolded lines from your black-and-white image and paint them on top of the original coloured image, that might end up producing what you're looking for.
If what you are trying to do is to use some filter over the B/W image and then use that with the original color. I suggest you convert your image to a color space with Lightness channel that suits your needs (for example L*a*b* if you need the ligtness to be uniformly distributed regarding human recognition of differences) and apply your filter only over the Lightness channel.