Label segmented cells with different colors - matlab

I am working with Matlab to extract cells from pathology images.
My codes successfully done the job and I can outline the cells by using 'bwperim'.
To outline the cell, my codes are:
perim=bwperim(selected_img);
r=img(:,:,1);
g=img(:,:,2);
b=img(:,:,3);
r(perim)=255;
g(perim)=0;
b(perim)=0;
img(:,:,1)=r;
img(:,:,2)=g;
img(:,:,3)=b;
And labeled the cells are:
But now I want to make the whole cell labeled with red, rather than just outline, what should I do?

It seems like you are looking for imfill:
mask = imfill(permi, 'holes');

Related

Letting big shadows bleed between UITableView cells

I've created a UITableViewCell with a textfield in it, which has a large diffused shadow underneath it. I've also set it up so that these big shadows can blend under its surrounding cells.
NB. Shadow has been HEAVILY emphasised here to show the problem.
The problem is that I want the shadow from my EMAIL textfield to blend underneath the password cell. i.e. I want both textfields to have a white background, but underneath them both I have the shadow. Something like this:
The reason this is a problem is because the UITableView is being rendered with upper cells "above" the lower ones. So any shadow from the cell at row 1 will bleed on top of the cells in rows 2, 3, 4 etc.
I was wondering if perhaps there is a way to change this rendering, and instead reverse the rendering so that a cell in row 4 is actually ABOVE rows 3, 2 and 1.
Or perhaps there is a way of setting the Password textfield so that no shadows are rendered on top of it?
Any help, very much appreciated!
Thanks to #Amr for pointing me in the direction of the cell.layer.zPosition.
The higher the value this is, the "closer" to the viewer the layer sits, so as long as each row has a higher value, it will appear "above" the shadows from any cells around it.
Since I use multiple sections in my code, I used this line to assign each cell above the previous one.
cell.layer.zPosition = CGFloat(indexPath.section) * 1000 + CGFloat(indexPath.row)

Can you color a cell based on another cell's contents in MS Word?

I have a project I'm working on with reports in MS Word that have similarly structured tables, but some of the cells are different colors depending on the report. To fill them in, I'm using a merge. I know I can format a cell or text based on the cell contents, but what about adjacent cells? I would like for cells to be shaded a light blue if the cells next to them have a specific text. Obviously this is easy in Excel, but is it possible in Word?

Nattable Cell with Multiple combination of images

We have a requirement to visualize a state of the cell.
Each cell represents user's DB CRUD access so each cell has four boolean flags for create, read, update and delete. To visualize, each cell should show four images with each image showing state of that flag.
We defined 8 labels (CREATE, NO_CREATE, READ, NO_READ etc) and adding these labels based on underlying model. So at any time, each cell will have 4 labels. We want to show 4 images in each cell with each image showing the state of corresponding flag.
Based on the research and from Dirk's suggestion, CellDecoratorPainter is the preferred approach. But each cell with a label is associated with one cell painter (in this case CellDecoratorPainter) so how do we use that to render combination of these images?
One approach I could think of is, instead of creating individual labels for READ, NO_READ etc., create 4x4x2 labels like READ_CREATE_UPDATE_DELETE, NO_READ_CREATE_UPDATE_DELETE and associate each of these labels with one cell painter decorator to paint series of images accordingly.
Not sure if that is the only possible approach. If any of you come across this type of situation, can you please share some thoughts?
PS: This is posted at Eclipse forums at https://www.eclipse.org/forums/index.php/m/1782700/#msg_1782700
It is suggested that we use custom image painter to achieve this as explained at https://www.eclipse.org/forums/index.php/m/1782739/#msg_1782739.
Snippet of response is
You could implement a custom ImagePainter that inspects the cell
labels and draws images based on the labels in the label stack. Or
stack CellPainterDecorators so that every decorator has an image as
decoration that is only painted in case of the cell label, and has
another decorator as base painter.
But honestly, writing a custom ImagePainter that inspects the labels and draws the images on occurence of a label seems to be more
intuitive.
We implemented CombinationImagePainter to achieve this and is available at https://gist.github.com/brsanthu/cd2f91da7777aa994e011f7acedd900a if you are interested.
We had a similar requirement wherein an image was to be displayed at the start and at the end. Almost the way you showed however we extended the AbstractTextPainter class and wrote the implementation according.

Create and display clickable cell of cells in Matlab GUI

So I want to display a cell matrix in Matlab GUI. Moreover, some of that cells are arrays of cells, and I want them to be clickable and that by clicking on them I activate a function.
Imagine I have a cell matrix:
A=cell(2,2);
A{1,1}='Collumn1';
A{1,2}='Collumn2';
A{2,1}={'A','B','C','D'};
A{2,2}={'E','F'};
I want to display it on an GUI, and I want to be able to click the cells, say to see the content of A{2,1}. Then I would like to click the cell entries in this cell array, and by doing so, I calculate a new matrix of the same form to display on the GUI.
However, uitable doesn't allow me to use a cell array.
An alternative would be to have a matrix of the form:
A=cell(5,2);
A{:,1}={'Collumn1','A',B',C',D'};
A{:,2}={'Numbers',1,2,3,4};
And by clicking the numbers (which I can do) a buttongroup would display (of undefined size), and by selecting one it would calculate a new matrix of the same form to display.
Thanks in advance.
Short answer: you can't
MATLAB GUI only provides only a very parse set of possible gui-elements check this documentation of MATLAB GUI. You need to change your request, so e.g. create an uitable or something like this. If you desire to create more advanced stuff in MATLAB GUI's, then you should start to look into this fellas documentation

How to change the background color of a table view cell after it was moved?

I have a table view with 9 rows at minimum. The background colors of the cells will depend of the cell position. If it is bellow to 3 or below to 6 or below to 9, the background color changes (see the next image).
The problem is that this table view can be reordered and I have to maintain the same color pattern. Example: if i change the 4th row to the 3th position, its background color must change from yellow to red.
To get the different colors, I used the method - (void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath, but this method is called only when the cell will be displayed and isn't good for reordering issues (the cell is already displayed and the color don't change).
I already tried to create a method to change the background color that is called just after the row was moved, but the color didn't changed (it seems that changing the background color with cell.backgroundColor property just works in - (void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath). :(
Any ideas how I can do that?
Thanks in advance.
Adjust the position in your data source however you are doing, then tell your data source to recalculate the colours for each item based on their current position. Then reload your table view. It should "just work".